Windows with "Always on Visible Workspace" on take focus/become the topmost window after switching workspaces
What Happened?
Title. Not shown in the recording, but it happens with both maximized and normal windows.
https://github.com/user-attachments/assets/fa10e8c2-7537-4578-8b32-6391e4c5d3f1
Steps to Reproduce
- Open window on workspace 1, make sure it's focused
- Open another window on workspace 2
- Turn on "Always on Visible Workspace" window context menu option
- Switch to workspace 1, window 2 is on top of window 1 despite it being focused before
Expected Behavior
Such window to act like a normal one, as in, not cover other windows unless purposefully focused.
OS Version
8.x (Circe)
OS Architecture
amd64 (on most hardwares)
Session Type
Classic and Secure Sessions (I have tested in both)
Software Version
Latest release (I have run all updates)
Log Output
Hardware Info
No response
The problem I see is that we can't know where to place it. We don't know where it should go in the stacking order of the other workspace because it is essentially a new window for that workspace so we treat it like one and place it on top. Or rather mutter places it on top afaicr we actually don't do anything. We could also place it at the bottom but idk whether that would make more sense. I guess we could place it directly below the last focused window on that workspace but that would also clash with some expectations. For example if I open my browser on one workspace to do some research and then move to another workspace and open a new browser window to do some other research. On the second workspace I open a notes app to take notes which is now focus. Now I want to take notes about the content in the other browser so I mark the notes app as always on visible workspace and switch workspace back. I would expect the notes app to be at the top
Another option could be to remember the stacking order if it was already on a workspace. But that would be really fragile. What if the stacking order on the remembered workspace changes while we aren't there? Where should we place it then? (App crashes, moving a window via the multitasking view, etc.) I personally prefer consistency over something that sometimes works 🤷
Seems to be a mutter issue indeed, upstream issue: https://gitlab.gnome.org/GNOME/mutter/-/issues/1599
Regarding Z index saving, I found that KDE does this and it works pretty well and is very natural; by default such windows stay on top on all desktops, but if some window is focused/new window is opened, the new window becomes the topmost one. Regarding the change of stacking order while the workspace is out of the view, KDE handles this by assuming that moved window is gone, so moving the window back to current workspace makes it the top window as it was just opened. I didn't test it thoroughly as I've done so in a VM, but it seems to be pretty much what we need.