LukeSmithxyz/dwm

sticky window unconditionally gets focused on switching tags

nudnyzjeb opened this issue · 4 comments

The way i understand focus stealing prevention works: on returing to a tag, focus the last window that had focus on that tag and not the window under the cursor. However if you sticky a window (mod+s), it then gets focus on switching tags no matter what.

  1. Give window-1 on tag 1 focus.
  2. Switch to tag 2 and spawn w-2, sticky it.
  3. Switch back to tag 1.
  4. ???
  5. w-2 gets focus, even though w-1 was supposed to get it.

WAIDW?

ejv2 commented

This happens when DWM calls the focus(NULL) function to select the window to focus on the current tag. The first one it comes across will always be the one which gets the focus on the new tag. This has the happy side-effect of causing windows on multiple tags to regain their focus across tag switches, but also causes this with sticky windows.

Offending code:

	if (!c || !ISVISIBLE(c))
		for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);

I think I wrote a patch for this in my build of DWM that fixes this with a small performance penalty (not usually noticeable to the user). Would you like me to open a pull request?

@ethanv2

I think I wrote a patch for this in my build of DWM that fixes this with a small performance penalty (not usually noticeable to the user). Would you like me to open a pull request?

Just post it... I need it too.

ejv2 commented

@asakura42 Done, see #181.

ejv2 commented

Patch for if you want to apply this to your own build: https://pastebin.com/raw/t1fGj0G0
If somebody wants to send this to the suckless hacking mailing list, please feel free.

You should close this issue now.