Add focusonactive patch to DWM

When an application tags itself as "active" i.e. has something to do,
this patch will ensure that we're focused on it.  Works on multiple
monitors!
This commit is contained in:
2025-11-26 03:23:30 +00:00
parent acd431e3ef
commit 879e7d351d
2 changed files with 66 additions and 2 deletions

11
dwm.c
View File

@@ -571,6 +571,7 @@ clientmessage(XEvent *e)
{
XClientMessageEvent *cme = &e->xclient;
Client *c = wintoclient(cme->window);
unsigned int i;
if (!c)
return;
@@ -585,8 +586,14 @@ clientmessage(XEvent *e)
setsticky(c, (cme->data.l[0] == 1 ||
(cme->data.l[0] == 2 && !c->issticky)));
} else if (cme->message_type == netatom[NetActiveWindow]) {
if (c != selmon->sel && !c->isurgent)
seturgent(c, 1);
for (i = 0; i < LENGTH(tags) && !((1 << i) & c->tags); i++);
if (i < LENGTH(tags)) {
const Arg a = {.ui = 1 << i};
selmon = c->mon;
view(&a);
focus(c);
restack(selmon);
}
}
}