[dev] dwm: Xkb brokenness
Hi all,
I use dwm with Xvnc, which apparently is broken when it comes to Xkb (or
maybe that's just my site installation). Anyway, I just installed the code
from the repository and it has a problem which I see has been reported
before: No keypresses work, because XkbKeycodeToKeysym always returns zero.
I did a little digging around and found a bug: You aren't supposed to use
any Xkb functions without calling XkbQueryExtension first, to initialize
the extension and test for its presence. I wrote this patch which adds the
XkbQueryExtension call, and uses XKeycodeToKeysym if you're one of the poor
souls without Xkb available.
Attached is the diff of my changes. Please let me know if there's a better
way for me to submit this patch.
--Neil
diff -r 0284f00e70d2 dwm.c
--- a/dwm.c Fri Nov 02 12:17:50 2012 +0100
+++ b/dwm.c Wed Nov 14 20:57:52 2012 -0300
_AT__AT_ -280,7 +280,7 @@
[UnmapNotify] = unmapnotify
};
static Atom wmatom[WMLast], netatom[NetLast];
-static Bool running = True;
+static Bool running = True, xkb_present;
static Cursor cursor[CurLast];
static Display *dpy;
static DC dc;
_AT__AT_ -1067,7 +1067,10 @@
XKeyEvent *ev;
ev = &e->xkey;
- keysym = XkbKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0, 0);
+ if (xkb_present)
+ keysym = XkbKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0,
0);
+ else
+ keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
for(i = 0; i < LENGTH(keys); i++)
if(keysym == keys[i].keysym
&& CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
_AT__AT_ -1577,6 +1580,7 @@
void
setup(void) {
XSetWindowAttributes wa;
+ int xkb_opcode, xkb_event, xkb_error, xkb_major = XkbMajorVersion,
xkb_minor = XkbMinorVersion;
/* clean up any zombies immediately */
sigchld(0);
_AT__AT_ -1629,6 +1633,8 @@
|EnterWindowMask|LeaveWindowMask|StructureNotifyMask|PropertyChangeMask;
XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa);
XSelectInput(dpy, root, wa.event_mask);
+ /* init xkb */
+ xkb_present = XkbQueryExtension(dpy, &xkb_opcode, &xkb_event,
&xkb_error, &xkb_major, &xkb_minor);
grabkeys();
}
Received on Thu Nov 15 2012 - 01:01:39 CET
This archive was generated by hypermail 2.3.0
: Thu Nov 15 2012 - 01:12:04 CET