Activate a window in response to _NET_ACTIVE_WINDOW

By default, dwm response to client requests to _NET_ACTIVE_WINDOW client
messages by setting the urgency bit on the named window.

This patch activates the window instead.

Both behaviours are legitimate according to
https://specifications.freedesktop.org/wm-spec/wm-spec-latest.html#idm140200472702304

One should decide which of these one should perform based on the message
senders' untestable claims that it represents the end-user. Setting the
urgency bit is the conservative decision. This patch implements the more
trusting alternative.

It also allows dwm to work with `wmctrl -a` and other external window
management utilities.
This commit is contained in:
Danny O'Brien
2017-12-23 16:45:29 -08:00
committed by Zoe Roux
parent e215d1e400
commit 1f809e3f81

10
dwm.c
View File

@@ -664,6 +664,7 @@ clientmessage(XEvent *e)
XSetWindowAttributes swa;
XClientMessageEvent *cme = &e->xclient;
Client *c = wintoclient(cme->window);
unsigned int i;
if (showsystray && systray && cme->window == systray->win && cme->message_type == netatom[NetSystemTrayOP]) {
/* add systray icons */
@@ -710,8 +711,13 @@ 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);
}
}
}