diff options
-rw-r--r-- | config.def.h | 2 | ||||
-rw-r--r-- | dwm.c | 26 |
2 files changed, 21 insertions, 7 deletions
diff --git a/config.def.h b/config.def.h index 8934ebd..71eab8f 100644 --- a/config.def.h +++ b/config.def.h @@ -1,7 +1,7 @@ /* See LICENSE file for copyright and license details. */ /* appearance */ -static const unsigned int borderpx = 3; /* border pixel of windows */ +static const unsigned int borderpx = 2; /* border pixel of windows */ static const unsigned int snap = 10; /* snap pixel */ static const int swallowfloating = 0; /* 1 means swallow floating windows by default */ static const unsigned int gappih = 15; /* horiz inner gap between windows */ @@ -1205,14 +1205,28 @@ grabkeys(void) { unsigned int i, j; unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask }; - KeyCode code; + int kc, kcmin, kcmax, kcper; + KeySym keysym, *keysyms; XUngrabKey(dpy, AnyKey, AnyModifier, root); - for (i = 0; i < LENGTH(keys); i++) - if ((code = XKeysymToKeycode(dpy, keys[i].keysym))) - for (j = 0; j < LENGTH(modifiers); j++) - XGrabKey(dpy, code, keys[i].mod | modifiers[j], root, - True, GrabModeAsync, GrabModeAsync); + + /* retrieve all the keycode -> keysym mappings */ + XDisplayKeycodes(dpy, &kcmin, &kcmax); + keysyms = XGetKeyboardMapping(dpy, kcmin, kcmax - kcmin + 1, &kcper); + + /* only look at the first keysym for each keycode as we handle shifted states */ + for (kc = kcmin; kc <= kcmax; kc++) { + keysym = keysyms[(kc - kcmin) * kcper]; + for (i = 0; i < LENGTH(keys); i++) { + if (keys[i].keysym == keysym) { + for (j = 0; j < LENGTH(modifiers); j++) { + XGrabKey(dpy, kc, keys[i].mod | modifiers[j], root, True, GrabModeAsync, GrabModeAsync); + } + } + } + } + + XFree(keysyms); } } |