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.
This commit is contained in:
Vlad Zahorodnii 2021-08-16 18:52:40 +03:00
parent 7c8d9c5b1c
commit 9962a9fe59

View file

@ -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