From d0908ad73536cee158b066645d8b993511ae9bdd Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 2 Apr 2014 19:39:08 +0200 Subject: [PATCH] use views geometries to calculate availableArea Don't trust anything X11: use our internal tracking of panel geometries to compute the corona availablescreenarea also because the space behind a panel not autohide but without struts is to be considered unavailable as well BUG:332850 --- src/shell/shellcorona.cpp | 83 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 77 insertions(+), 6 deletions(-) diff --git a/src/shell/shellcorona.cpp b/src/shell/shellcorona.cpp index 743fc5431..24617a552 100644 --- a/src/shell/shellcorona.cpp +++ b/src/shell/shellcorona.cpp @@ -320,20 +320,87 @@ int ShellCorona::numScreens() const QRect ShellCorona::screenGeometry(int id) const { - return QApplication::desktop()->screenGeometry(id); + DesktopView *view = 0; + foreach (DesktopView *v, d->views) { + if (v->containment() && v->containment()->screen() == id) { + view = v; + break; + } + } + + if (view) { + return view->geometry(); + } else { + return QApplication::desktop()->screenGeometry(id); + } } QRegion ShellCorona::availableScreenRegion(int id) const { - return QApplication::desktop()->availableGeometry(id); + DesktopView *view = 0; + foreach (DesktopView *v, d->views) { + if (v->containment() && v->containment()->screen() == id) { + view = v; + break; + } + } + + if (view) { + QRegion r = view->geometry(); + foreach (PanelView *v, d->panelViews.values()) { + if (v->containment()->screen() == id && v->visibilityMode() != PanelView::AutoHide) { + r -= v->geometry(); + } + } + return r; + } else { + return QApplication::desktop()->availableGeometry(id); + } } QRect ShellCorona::availableScreenRect(int id) const { - //return QApplication::desktop()->availableGeometry(id); - //FIXME: revert back to this^ after https://codereview.qt-project.org/#change,80606 has been merged - // and released (and we depend on it) - return KWindowSystem::workArea(id).intersect(QApplication::desktop()->availableGeometry(id)); + if (id < 0) { + id = 0; + } + + QRect r(screenGeometry(id)); + + foreach (PanelView *view, d->panelViews.values()) { + if (view->containment()->screen() == id && view->visibilityMode() != PanelView::AutoHide) { + QRect v = view->geometry(); + switch (view->location()) { + case Plasma::Types::TopEdge: + if (v.bottom() > r.top()) { + r.setTop(v.bottom()); + } + break; + + case Plasma::Types::BottomEdge: + if (v.top() < r.bottom()) { + r.setBottom(v.top()); + } + break; + + case Plasma::Types::LeftEdge: + if (v.right() > r.left()) { + r.setLeft(v.right()); + } + break; + + case Plasma::Types::RightEdge: + if (v.left() < r.right()) { + r.setRight(v.left()); + } + break; + + default: + break; + } + } + } + + return r; } PanelView *ShellCorona::panelView(Plasma::Containment *containment) const @@ -448,9 +515,13 @@ void ShellCorona::createWaitingPanels() connect(cont, &PanelView::destroyed, [=](QObject *obj) { d->panelViews.remove(cont); + emit availableScreenRectChanged(); + emit availableScreenRegionChanged(); }); } d->waitingPanels.clear(); + emit availableScreenRectChanged(); + emit availableScreenRegionChanged(); } void ShellCorona::handleContainmentAdded(Plasma::Containment* c)