dwm
dynamic window manager
git clone https://9o.is/git/dwm.git
commit a438297a487a975fbe016e7b3e2f4b06d1a5c83b parent 967407d6f94acd6bc27e686b813ff21aa6db2585 Author: Jul <jul@9o.is> Date: Thu, 19 Feb 2026 17:18:31 +0800 focus on window activation Diffstat:
| M | dwm.c | | | 12 | ++++++++++-- |
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/dwm.c b/dwm.c @@ -243,6 +243,7 @@ static void updatewmhints(Client *c); static void updatecentered(Client *c); static void updatetagprop(Client *c); static void view(const Arg *arg); +static void warpmouse(void); static Client *wintoclient(Window w); static Monitor *wintomon(Window w); static int xerror(Display *dpy, XErrorEvent *ee); @@ -579,6 +580,7 @@ clientmessage(XEvent *e) { XClientMessageEvent *cme = &e->xclient; Client *c = wintoclient(cme->window); + unsigned int i; if (!c) return; @@ -588,8 +590,14 @@ clientmessage(XEvent *e) setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */ || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen))); } 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}; + view(&a); + focus(c); + restack(selmon); + warpmouse(); + } } }