about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAcid Bong <acid-bong@cock.lt>2022-12-28 18:49:06 +0200
committerAcid Bong <acid-bong@cock.lt>2022-12-29 21:44:24 +0200
commit896b6c49aad3e351f528fcbf9c141473ff5cf264 (patch)
tree06bb7f06ef3ea592a9b476700710062eccf01762
parenta3ef99f743e79604e0e0b2f7bab38e3cea4dc091 (diff)
parent89f9905714c1c1b2e8b09986dfbeca15b68d8af8 (diff)
downloaddwm-896b6c49aad3e351f528fcbf9c141473ff5cf264.tar.gz
Merge branch 'master' into bong
-rw-r--r--dwm.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/dwm.c b/dwm.c
index bd29dc7..5aaf9df 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1236,16 +1236,26 @@ grabkeys(void)
 {
 	updatenumlockmask();
 	{
-		unsigned int i, j;
+		unsigned int i, j, k;
 		unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
-		KeyCode code;
+		int start, end, skip;
+		KeySym *syms;
 
 		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);
+		XDisplayKeycodes(dpy, &start, &end);
+		syms = XGetKeyboardMapping(dpy, start, end - start + 1, &skip);
+		if (!syms)
+			return;
+		for (k = start; k <= end; k++)
+			for (i = 0; i < LENGTH(keys); i++)
+				/* skip modifier codes, we do that ourselves */
+				if (keys[i].keysym == syms[(k - start) * skip])
+					for (j = 0; j < LENGTH(modifiers); j++)
+						XGrabKey(dpy, k,
+							 keys[i].mod | modifiers[j],
+							 root, True,
+							 GrabModeAsync, GrabModeAsync);
+		XFree(syms);
 	}
 }
 
@@ -2076,6 +2086,8 @@ sigterm(int unused)
 void
 spawn(const Arg *arg)
 {
+	if (arg->v == dmenucmd)
+		dmenumon[0] = '0' + selmon->num;
 	if (fork() == 0) {
 		if (dpy)
 			close(ConnectionNumber(dpy));