From 6f406634783c2b19a90fcad229f706a48e65cc3e Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Thu, 2 Aug 2018 14:23:01 +0300 Subject: [PATCH] Identify snapped windows independent of screen --the old code wasnt screen independent for identifying windows that touch the panel edge. There were cases that when a window was touching a panel edge at screen A to faulty identify that is touching screen B also. The code now is more robust and it can also handle cases that window is touching two or more different panels in different screens. BUG: 397076 FIXED-IN: 0.8.1 (cherry picked from commit 7bceb7e4b752955c0a9be79f57b0485c9271e1ef) --- app/dock/visibilitymanager.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/app/dock/visibilitymanager.cpp b/app/dock/visibilitymanager.cpp index d8a4fc970..2417ce5d2 100644 --- a/app/dock/visibilitymanager.cpp +++ b/app/dock/visibilitymanager.cpp @@ -25,6 +25,7 @@ #include "screenedgeghostwindow.h" #include "../dockcorona.h" #include "../layoutmanager.h" +#include "../screenpool.h" #include "../windowinfowrap.h" #include "../../liblattedock/extras.h" @@ -778,7 +779,8 @@ void VisibilityManagerPrivate::updateAvailableScreenGeometry() return; } - QRect tempAvailableScreenGeometry = dockCorona->availableScreenRectWithCriteria(view->containment()->screen(), {Dock::AlwaysVisible}, {}); + int currentScrId = dockCorona->screenPool()->id(dockView->currentScreen()); + QRect tempAvailableScreenGeometry = dockCorona->availableScreenRectWithCriteria(currentScrId, {Dock::AlwaysVisible}, {}); if (tempAvailableScreenGeometry != availableScreenGeometry) { availableScreenGeometry = tempAvailableScreenGeometry; @@ -861,14 +863,19 @@ void VisibilityManagerPrivate::updateDynamicBackgroundWindowFlags() bool touchingPanelEdge{false}; - if (view->location() == Plasma::Types::TopEdge) { - touchingPanelEdge = (winfo.geometry().y() == availableScreenGeometry.y()); - } else if (view->location() == Plasma::Types::BottomEdge) { - touchingPanelEdge = (winfo.geometry().bottom() == availableScreenGeometry.bottom()); - } else if (view->location() == Plasma::Types::LeftEdge) { - touchingPanelEdge = (winfo.geometry().x() == availableScreenGeometry.x()); - } else if (view->location() == Plasma::Types::RightEdge) { - touchingPanelEdge = (winfo.geometry().right() == availableScreenGeometry.right()); + QRect screenGeometry = dockView->screenGeometry(); + bool inCurrentScreen{screenGeometry.contains(winfo.geometry().topLeft()) || screenGeometry.contains(winfo.geometry().bottomRight())}; + + if (inCurrentScreen) { + if (view->location() == Plasma::Types::TopEdge) { + touchingPanelEdge = (winfo.geometry().y() == availableScreenGeometry.y()); + } else if (view->location() == Plasma::Types::BottomEdge) { + touchingPanelEdge = (winfo.geometry().bottom() == availableScreenGeometry.bottom()); + } else if (view->location() == Plasma::Types::LeftEdge) { + touchingPanelEdge = (winfo.geometry().x() == availableScreenGeometry.x()); + } else if (view->location() == Plasma::Types::RightEdge) { + touchingPanelEdge = (winfo.geometry().right() == availableScreenGeometry.right()); + } } if (((winfo.isActive() || winfo.isKeepAbove()) && touchingPanelEdge)