improve availableScreen..WithCriteria api

--improve its semantics in order to be more
understandable
pull/11/head
Michail Vourlakos 5 years ago
parent e6ba47daab
commit d1faaedc59

@ -532,7 +532,7 @@ QRegion Corona::availableScreenRegionWithCriteria(int id,
QString forLayout, QString forLayout,
QList<Types::Visibility> ignoreModes, QList<Types::Visibility> ignoreModes,
QList<Plasma::Types::Location> ignoreEdges, QList<Plasma::Types::Location> ignoreEdges,
bool includeExternalPanels) const bool ignoreExternalPanels) const
{ {
const QScreen *screen = m_screenPool->screenForId(id); const QScreen *screen = m_screenPool->screenForId(id);
CentralLayout *layout = centralLayout(forLayout); CentralLayout *layout = centralLayout(forLayout);
@ -541,20 +541,28 @@ QRegion Corona::availableScreenRegionWithCriteria(int id,
return {}; return {};
} }
QRegion available = includeExternalPanels ? screen->availableGeometry() : screen->geometry(); QRegion available = ignoreExternalPanels ? screen->geometry() : screen->availableGeometry();
if (!layout) { if (!layout) {
return available; return available;
} }
bool allModes = ignoreModes.isEmpty(); //! blacklist irrelevant visibility modes
if (!ignoreModes.contains(Latte::Types::None)) {
ignoreModes << Latte::Types::None;
}
if (!ignoreModes.contains(Latte::Types::NormalWindow)) {
ignoreModes << Latte::Types::NormalWindow;
}
bool allEdges = ignoreEdges.isEmpty(); bool allEdges = ignoreEdges.isEmpty();
QList<Latte::View *> views = layout->latteViews(); QList<Latte::View *> views = layout->latteViews();
for (const auto *view : views) { for (const auto *view : views) {
if (view && view->containment() && view->screen() == screen if (view && view->containment() && view->screen() == screen
&& ((allEdges || !ignoreEdges.contains(view->location())) && ((allEdges || !ignoreEdges.contains(view->location()))
&& (allModes || (view->visibility() && !ignoreModes.contains(view->visibility()->mode()))))) { && (view->visibility() && !ignoreModes.contains(view->visibility()->mode())))) {
int realThickness = view->normalThickness(); int realThickness = view->normalThickness();
// Usually availableScreenRect is used by the desktop, // Usually availableScreenRect is used by the desktop,
@ -711,7 +719,7 @@ QRect Corona::availableScreenRectWithCriteria(int id,
QString forLayout, QString forLayout,
QList<Types::Visibility> ignoreModes, QList<Types::Visibility> ignoreModes,
QList<Plasma::Types::Location> ignoreEdges, QList<Plasma::Types::Location> ignoreEdges,
bool includeExternalPanels) const bool ignoreExternalPanels) const
{ {
const QScreen *screen = m_screenPool->screenForId(id); const QScreen *screen = m_screenPool->screenForId(id);
CentralLayout *layout = centralLayout(forLayout); CentralLayout *layout = centralLayout(forLayout);
@ -720,20 +728,28 @@ QRect Corona::availableScreenRectWithCriteria(int id,
return {}; return {};
} }
QRect available = includeExternalPanels ? screen->availableGeometry() : screen->geometry(); QRect available = ignoreExternalPanels ? screen->geometry() : screen->availableGeometry();
if (!layout) { if (!layout) {
return available; return available;
} }
bool allModes = ignoreModes.isEmpty(); //! blacklist irrelevant visibility modes
if (!ignoreModes.contains(Latte::Types::None)) {
ignoreModes << Latte::Types::None;
}
if (!ignoreModes.contains(Latte::Types::NormalWindow)) {
ignoreModes << Latte::Types::NormalWindow;
}
bool allEdges = ignoreEdges.isEmpty(); bool allEdges = ignoreEdges.isEmpty();
QList<Latte::View *> views = layout->latteViews(); QList<Latte::View *> views = layout->latteViews();
for (const auto *view : views) { for (const auto *view : views) {
if (view && view->containment() && view->screen() == screen if (view && view->containment() && view->screen() == screen
&& ((allEdges || !ignoreEdges.contains(view->location())) && ((allEdges || !ignoreEdges.contains(view->location()))
&& (allModes || (view->visibility() && !ignoreModes.contains(view->visibility()->mode()))))) { && (view->visibility() && !ignoreModes.contains(view->visibility()->mode())))) {
// Usually availableScreenRect is used by the desktop, // Usually availableScreenRect is used by the desktop,
// but Latte don't have desktop, then here just // but Latte don't have desktop, then here just

@ -109,19 +109,19 @@ public:
//! This is a very generic function in order to return the availableScreenRect of specific screen //! This is a very generic function in order to return the availableScreenRect of specific screen
//! by calculating only the user specified visibility modes and edges. Empty QLists for both //! by calculating only the user specified visibility modes and edges. Empty QLists for both
//! arguments mean that all choices are accepted in calculations. includeExternalPanels means that //! arguments mean that all choices are accepted in calculations. ignoreExternalPanels means that
//! external panels should be considered in the calculations //! external panels should be not considered in the calculations
QRect availableScreenRectWithCriteria(int id, QRect availableScreenRectWithCriteria(int id,
QString forLayout = QString(), QString forLayout = QString(),
QList<Types::Visibility> ignoreModes = QList<Types::Visibility>(), QList<Types::Visibility> ignoreModes = QList<Types::Visibility>(),
QList<Plasma::Types::Location> ignoreEdges = QList<Plasma::Types::Location>(), QList<Plasma::Types::Location> ignoreEdges = QList<Plasma::Types::Location>(),
bool includeExternalPanels = false) const; bool ignoreExternalPanels = true) const;
QRegion availableScreenRegionWithCriteria(int id, QRegion availableScreenRegionWithCriteria(int id,
QString forLayout = QString(), QString forLayout = QString(),
QList<Types::Visibility> ignoreModes = QList<Types::Visibility>(), QList<Types::Visibility> ignoreModes = QList<Types::Visibility>(),
QList<Plasma::Types::Location> ignoreEdges = QList<Plasma::Types::Location>(), QList<Plasma::Types::Location> ignoreEdges = QList<Plasma::Types::Location>(),
bool includeExternalPanels = false) const; bool ignoreExternalPanels = true) const;
int screenForContainment(const Plasma::Containment *containment) const override; int screenForContainment(const Plasma::Containment *containment) const override;

@ -231,7 +231,7 @@ void PrimaryConfigView::deleteSecondaryWindow()
void PrimaryConfigView::updateAvailableScreenGeometry(View *origin) void PrimaryConfigView::updateAvailableScreenGeometry(View *origin)
{ {
int currentScrId = m_latteView->positioner()->currentScreenId(); int currentScrId = m_latteView->positioner()->currentScreenId();
m_availableScreenGeometry = m_corona->availableScreenRectWithCriteria(currentScrId, QString(), {}, {}, true); m_availableScreenGeometry = m_corona->availableScreenRectWithCriteria(currentScrId, QString(), {}, {}, false);
emit availableScreenGeometryChanged(); emit availableScreenGeometryChanged();
} }

Loading…
Cancel
Save