[dev] [PATCH] dwm: replace deprecated XKeycodeToKeysym

From: Antonio Quartulli <ordex_AT_autistici.org>
Date: Tue, 11 Dec 2012 09:35:12 +0100

XKeycodeToKeysym is now deprecated in favour of XkbKeycodeToKeysym
(X11/XKBlib.h). This patch substitutes the former with the latter in dwm.c

Signed-off-by: Antonio Quartulli <ordex_AT_autistici.org>
---
 dwm.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/dwm.c b/dwm.c
index d9443da..3ad3bf2 100644
--- a/dwm.c
+++ b/dwm.c
_AT_@ -33,6 +33,7 @@
 #include <X11/cursorfont.h>
 #include <X11/keysym.h>
 #include <X11/Xatom.h>
+#include <X11/XKBlib.h>
 #include <X11/Xlib.h>
 #include <X11/Xproto.h>
 #include <X11/Xutil.h>
_AT_@ -1080,7 +1081,7 @@ keypress(XEvent *e) {
 	XKeyEvent *ev;
 
 	ev = &e->xkey;
-	keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
+	keysym = XkbKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0, 0);
 	for(i = 0; i < LENGTH(keys); i++)
 		if(keysym == keys[i].keysym
 		&& CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
_AT_@ -1413,6 +1414,20 @@ resizemouse(const Arg *arg) {
 		focus(NULL);
 	}
 }
+void
+setwmname(const char *name) {
+	Window wincheck = XCreateSimpleWindow(dpy, root, -10, -10, 5, 5, 0, 0, 0);
+
+	if(wincheck != None) {
+		Atom m_net_supporting_wm_check = XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False);
+		Atom utf8_string = XInternAtom(dpy, "UTF8_STRING", False);
+
+		XChangeProperty(dpy, root, m_net_supporting_wm_check, XA_WINDOW, 32, PropModeReplace, (unsigned char *)&wincheck, 1);
+		XChangeProperty(dpy, wincheck, m_net_supporting_wm_check, XA_WINDOW, 32, PropModeReplace, (unsigned char *)&wincheck, 1);
+		XChangeProperty(dpy, wincheck, netatom[NetWMName], utf8_string, 8, PropModeReplace, (unsigned char *)name, strlen(name));
+	}
+}
+
 
 void
 restack(Monitor *m) {
_AT_@ -1615,6 +1630,7 @@ setup(void) {
 	netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False);
 	netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
 	netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False);
+	setwmname("LG3D");
 	/* init cursors */
 	cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
 	cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
_AT_@ -1626,6 +1642,9 @@ setup(void) {
 	dc.sel[ColBorder] = getcolor(selbordercolor);
 	dc.sel[ColBG] = getcolor(selbgcolor);
 	dc.sel[ColFG] = getcolor(selfgcolor);
+	dc.urg[ColBorder] = getcolor(urgbordercolor);
+	dc.urg[ColBG] = getcolor(selbgcolor);
+	dc.urg[ColFG] = getcolor(selfgcolor);
 	dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), bh, DefaultDepth(dpy, screen));
 	dc.gc = XCreateGC(dpy, root, 0, NULL);
 	XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
-- 
1.8.0
Received on Tue Dec 11 2012 - 09:35:12 CET

This archive was generated by hypermail 2.3.0 : Tue Dec 11 2012 - 09:48:04 CET