summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.def.h2
-rw-r--r--dwm.c26
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 */
diff --git a/dwm.c b/dwm.c
index 42c43f6..dccbc0a 100644
--- a/dwm.c
+++ b/dwm.c
@@ -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);
}
}