about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorarg@10ksloc.org <unknown>2006-08-01 12:41:38 +0200
committerarg@10ksloc.org <unknown>2006-08-01 12:41:38 +0200
commit57416beefec4db451a75a1d25434b69cf50badad (patch)
tree14f9a0a7db23ba48e6ea986364fecae205d62c40
parent1b63f832c528958042d72fddc318af5aefdcb68a (diff)
downloaddwm-57416beefec4db451a75a1d25434b69cf50badad.tar.gz
applied Cedric's NumLock patch
-rw-r--r--event.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/event.c b/event.c
index 2cebc9e..f177cbe 100644
--- a/event.c
+++ b/event.c
@@ -57,6 +57,9 @@ static Key key[] = {
 	{ MODKEY|ShiftMask,	XK_w,		spawn,		{ .argv = browse } },
 };
 
+#define NumLockMask Mod2Mask
+unsigned int valid_mask =  255 &  ~( NumLockMask | LockMask);
+
 /* END CUSTOMIZE */
 
 /* static */
@@ -271,10 +274,11 @@ keypress(XEvent *e)
 	unsigned int i;
 	KeySym keysym;
 	XKeyEvent *ev = &e->xkey;
+	ev->state &= valid_mask;
 
 	keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
 	for(i = 0; i < len; i++)
-		if((keysym == key[i].keysym) && (key[i].mod == ev->state)) {
+		if((keysym == key[i].keysym) && ((key[i].mod & valid_mask) == ev->state)) {
 			if(key[i].func)
 				key[i].func(&key[i].arg);
 			return;
@@ -377,7 +381,19 @@ grabkeys()
 	for(i = 0; i < len; i++) {
 		code = XKeysymToKeycode(dpy, key[i].keysym);
 		XUngrabKey(dpy, code, key[i].mod, root);
+		if (NumLockMask)
+		{
+			XUngrabKey(dpy, code, key[i].mod | NumLockMask, root);
+			XUngrabKey(dpy, code, key[i].mod | NumLockMask | LockMask, root);
+		}
 		XGrabKey(dpy, code, key[i].mod, root, True,
 				GrabModeAsync, GrabModeAsync);
+		if (NumLockMask)
+		{
+			XGrabKey(dpy, code, key[i].mod | NumLockMask, root, True,
+					GrabModeAsync, GrabModeAsync);
+			XGrabKey(dpy, code, key[i].mod | NumLockMask | LockMask, root, True,
+					GrabModeAsync, GrabModeAsync);
+		}
 	}
 }
for the pointer to Uriel)' href='/acidbong/suckless/dwm/commit/util.c?h=5.8.2&id=6a3ae5e26a5cebfd35f2423aec0c47843b5a85be'>6a3ae5e ^
39677ec ^


39677ec ^
ca65478 ^
adaa28a ^
dc5d967 ^
adaa28a ^


849e631 ^
adaa28a ^


2c477cf ^
9955ddc ^
dc5d967 ^
9955ddc ^

2c477cf ^
439e15d ^
4230932 ^

439e15d ^



16c67f3 ^
2c477cf ^

439e15d ^

0464e42 ^
439e15d ^


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52