From 9962a9fe59553aa9f225fbb0fbcddb122231cce4 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Mon, 16 Aug 2021 18:52:40 +0300 Subject: [PATCH] Consider only windows on current desktop when snapping them If a window is on several desktops, AbstractClient::desktop() will return the id of the last desktop. For example, if a window is on virtual desktops A and B, the desktop() function will return the id of desktop B. This can be the culprit for bugs such as window snapping not working as expected when moving a window on virtual desktop A, e.g. - moved window is on desktops A, and C. desktop() returns the id of C - snap candidate (l) is on desktops A, and B. desktop() returns the id of B Even though the snap candidate window and the moved window are both on the same desktop (A), the moved window won't be snapped because the desktop() function returns garbage values. To fix that, the workspace needs to check whether the window is on the current desktop. For what it's worth, that's also how the workspace handles windows being on multiple activities. --- src/workspace.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/workspace.cpp b/src/workspace.cpp index 67d7c27106..6b2dea4593 100644 --- a/src/workspace.cpp +++ b/src/workspace.cpp @@ -2536,7 +2536,7 @@ QPoint Workspace::adjustClientPosition(AbstractClient* c, QPoint pos, bool unres continue; // is minimized if (!(*l)->isShown(false)) continue; - if (!((*l)->isOnDesktop(c->desktop()) || c->isOnDesktop((*l)->desktop()))) + if (!(*l)->isOnCurrentDesktop()) continue; // wrong virtual desktop if (!(*l)->isOnCurrentActivity()) continue; // wrong activity