[hackers] [dwm][PATCH] Set the EWMH _NET_SUPPORTING_WM_CHECK atom

From: Omar Sandoval <osandov_AT_osandov.com>
Date: Sat, 23 Jan 2016 16:10:41 -0800

---
This has been discussed a couple of times [1][2], and I think it's about time
that it gets fixed. I noticed this issue because xfce4-screenshooter -w, which
is supposed to screenshot the active window, doesn't work with dwm. After
digging through the source code, I found that it uses
gdk_screen_get_active_window() [3]. According to the documentation, that
function looks at _NET_ACTIVE_WINDOW, which dwm sets. Looking at the GDK source
code, I found that gdk_x11_screen_supports_net_wm_hint() [4] returns false for
_NET_ACTIVE_WINDOW on dwm regardless of the value of _NET_SUPPORTED because
_NET_SUPPORTING_WM_CHECK is not set (see fetch_net_wm_check_window() [5]).
tl;dr Not setting _NET_SUPPORTING_WM_CHECK breaks real applications, and dwm is
already going through the trouble of setting several EWMH atoms, so we should
fix this.
1: http://lists.suckless.org/dev/1411/24636.html
2: http://lists.suckless.org/dev/1505/26735.html
3: https://developer.gnome.org/gdk2/stable/GdkScreen.html#gdk-screen-get-active-window
4: https://git.gnome.org/browse/gtk+/tree/gdk/x11/gdkscreen-x11.c?h=3.19.7#n1635
5: https://git.gnome.org/browse/gtk+/tree/gdk/x11/gdkscreen-x11.c?h=3.19.7#n1580
 dwm.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/dwm.c b/dwm.c
index ff7e096f61fc..7c12796419ca 100644
--- a/dwm.c
+++ b/dwm.c
_AT_@ -60,7 +60,7 @@
 /* enums */
 enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
 enum { SchemeNorm, SchemeSel, SchemeLast }; /* color schemes */
-enum { NetSupported, NetWMName, NetWMState,
+enum { NetSupported, NetSupportingWMCheck, NetWMName, NetWMState,
        NetWMFullscreen, NetActiveWindow, NetWMWindowType,
        NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
 enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
_AT_@ -1574,6 +1574,7 @@ setup(void)
 	wmatom[WMTakeFocus] = XInternAtom(dpy, "WM_TAKE_FOCUS", False);
 	netatom[NetActiveWindow] = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
 	netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
+	netatom[NetSupportingWMCheck] = XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False);
 	netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
 	netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False);
 	netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False);
_AT_@ -1806,6 +1807,8 @@ updatebars(void)
 		.background_pixmap = ParentRelative,
 		.event_mask = ButtonPressMask|ExposureMask
 	};
+	Atom utf8string;
+	utf8string = XInternAtom(dpy, "UTF8_STRING", False);
 	for (m = mons; m; m = m->next) {
 		if (m->barwin)
 			continue;
_AT_@ -1814,7 +1817,14 @@ updatebars(void)
 		                          CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
 		XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor);
 		XMapRaised(dpy, m->barwin);
+		XChangeProperty(dpy, m->barwin, netatom[NetWMName], utf8string,
+				8, PropModeReplace, (unsigned char *)"dwm", 3);
 	}
+	/* it doesn't matter which bar we use for this, so just use the first one */
+	XChangeProperty(dpy, root, netatom[NetSupportingWMCheck], XA_WINDOW, 32,
+			PropModeReplace, (unsigned char *)&mons->barwin, 1);
+	XChangeProperty(dpy, mons->barwin, netatom[NetSupportingWMCheck], XA_WINDOW,
+			32, PropModeReplace, (unsigned char *)&mons->barwin, 1);
 }
 
 void
-- 
2.7.0
Received on Sun Jan 24 2016 - 01:10:41 CET

This archive was generated by hypermail 2.3.0 : Sun Jan 24 2016 - 01:12:16 CET