Defer focusing on sticky windows on switching tags

focus(NULL) is called when switching to a new tag or monitor.  I don't
want sticky windows to get first focus in this situation, hence this
code.  Shamelessly stolen from
https://github.com/LukeSmithxyz/dwm/issues/152.
This commit is contained in:
2024-07-24 16:21:12 +01:00
parent a5ef1a0a85
commit 7c67af1e81

10
dwm.c
View File

@@ -906,8 +906,14 @@ expose(XEvent *e)
void
focus(Client *c)
{
if (!c || !ISVISIBLE(c))
for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
if (!c || !ISVISIBLE(c)) {
for (c = selmon->stack; c &&
(!ISVISIBLE(c) || (c->issticky && !selmon->sel->issticky));
c = c->snext);
if (!c) /* No windows found; check for available stickies */
for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
}
if (selmon->sel && selmon->sel != c)
unfocus(selmon->sel, 0);
if (c) {