Score:1

How to lock the workspaces shown in wayland / prevent other apps from changing the workspace?

tr flag

Please note that this question is entirely different from

Because this question here is NOT about how to

  • open a program on the current workspace. I know that.
  • open a program on a different workspace. I know that.
  • prevent a window from moving to some workspace. I know how to handle that.
  • prevent switching a workspace when clicking on an icon or use the task switcher.

This question also is NOT about chromium. Chromium is only the most prominent app one out of many applications which misbehave.

The question is how to prevent Wayland from switching the current workspace when another application tries to switch the focus to itself (like chromium or others) without direct user interaction. This is something like focus stealing, which is annoying enough when it happens on the current workspace.

If I chose a workspace with Compiz, this workspace must not be changed until I chose a different one, regardless what other applications try to do in the background.

Is there perhaps a way to tell Wayland to only obey a switching command from certain applications like Compiz and wmctrl? Can this, perhaps, be reached with some dbus filter (even that I know how to hack the code of Linux kernel modules like CIFS or ZFS to my needs, I really do not grok dbus nor Wayland nor SystemD yet, sorry). LD_PRELOAD? Some (existing) X0 protocol firewall? Anything?

My current workaround is to run

while sleep .01; do DISPLAY=:0 wmctrl -s 2; done

This way, if chromium (or one of the other apps) switches the workspace, Wayland immediately switches back to the one I work on. However this minute long steady screen flicker due to this switching back and forth is irritating. Also sometimes the mouse focus gets lost (or something completely different happens like dropping something onto the wrong desktop due to the race condition exposed) due to the flicker.

Note that chromium is the most annoying one. Most other apps just switch the workspace a single time. Chromium, however, apparently does this for each window it opens when it starts. With several thousand windows open at my side the entire start of chrome takes minutes (my machine has enough RAM and CPU, so this is not a swapping issue), and while it starts up, it steadily tries to switch the workspace until it is ready. However the question also is about how to prevent FireFox, IDEs and other windows from stealing the focus this way.

Please note that this question is not about focus stealing itself. It is just about focus stealing by switching the workspace, because this is something completely different than the normal focus stealing observed.

So I do not want to prevent windows from jumping around, move to another workspace or steal the focus on the current workspace. So Apps are still allowed to ruin my window placement.

All I want is to "lock into" the current workspace such, that nothing else is allowed to change it until I chose to move to another workspace.


Some thoughts to this:

Wayland only presents a certain part (the Workspace) of a much bigger canvas (which holds all Workspaces). So changing the workspace is just changing the origin from where the canvas is shown. And the displays are areas relatively to this origin. (Of course there is a bit more going on, as the input focus has to be moved, too.)

AFAICS it should be easy to prevent the origin from being moved (and thereby preventing the change of the focus, too). That's exactly what I want to archive. Perhaps this already is built into Wayland somewhere. Or it could be hacked into the code, something like a firewall which prevents changing the origin by unauthorized apps. This is something I could implement, if I were able to find the right location where this is origin change happens in Wayland.

But before digging into this (which probably take several days) I want to know if there perhaps is some better or standard way to archive that.


Some final note:

I need to use Ubuntu and Wayland, as my display setup / Hardware / HWE stack is unsupported under plain X11. (It is unable to correctly drive one of my monitors. Note that I very likely have the abilities to find this bug and repair it, however I lack the time to do so.)

So changing away from Wayland does not help at my side. Of course I run LTS, so Ubuntu 22.04 is also set, so changing the OS is of no help either.

vanadium avatar
cn flag
How is this totally different from focus stealing? As soon as an application gains focus without you manually focusing the window, there is "focus stealing". And indeed, if the application happens to be on a different workspace, that will bring you on that workspace.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.