dwm-focusonnetactive-6.2.diff (1719B)
1 From 286ca3bb1af08b452bf8140abcc23d4ef61baaa2 Mon Sep 17 00:00:00 2001 2 From: bakkeby <bakkeby@gmail.com> 3 Date: Tue, 7 Apr 2020 12:33:04 +0200 4 Subject: [PATCH] Activate a window in response to _NET_ACTIVE_WINDOW 5 6 By default, dwm response to client requests to _NET_ACTIVE_WINDOW client 7 messages by setting the urgency bit on the named window. 8 9 This patch activates the window instead. 10 11 Both behaviours are legitimate according to 12 https://specifications.freedesktop.org/wm-spec/wm-spec-latest.html#idm140200472702304 13 14 One should decide which of these one should perform based on the message 15 senders' untestable claims that it represents the end-user. Setting the 16 urgency bit is the conservative decision. This patch implements the more 17 trusting alternative. 18 19 It also allows dwm to work with `wmctrl -a` and other external window 20 management utilities 21 22 --- 23 dwm.c | 11 +++++++++-- 24 1 file changed, 9 insertions(+), 2 deletions(-) 25 26 diff --git a/dwm.c b/dwm.c 27 index 4465af1..3919d47 100644 28 --- a/dwm.c 29 +++ b/dwm.c 30 @@ -514,6 +514,7 @@ clientmessage(XEvent *e) 31 { 32 XClientMessageEvent *cme = &e->xclient; 33 Client *c = wintoclient(cme->window); 34 + unsigned int i; 35 36 if (!c) 37 return; 38 @@ -523,8 +524,14 @@ clientmessage(XEvent *e) 39 setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */ 40 || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen))); 41 } else if (cme->message_type == netatom[NetActiveWindow]) { 42 - if (c != selmon->sel && !c->isurgent) 43 - seturgent(c, 1); 44 + for (i = 0; i < LENGTH(tags) && !((1 << i) & c->tags); i++); 45 + if (i < LENGTH(tags)) { 46 + const Arg a = {.ui = 1 << i}; 47 + selmon = c->mon; 48 + view(&a); 49 + focus(c); 50 + restack(selmon); 51 + } 52 } 53 } 54 55 -- 56 2.17.1 57