Skip to content

Consider only windows on current desktop when snapping them

Vlad Zahorodnii requested to merge work/window-snap-current-desktop into master

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.

Edited by Vlad Zahorodnii

Merge request reports