aewl
diff event.c @ 145:774754477c35
applied Cedric's NumLock patch
author | arg@10ksloc.org |
---|---|
date | Tue, 01 Aug 2006 12:41:38 +0200 |
parents | e61447a7f249 |
children | f328ce9c558c |
line diff
1.1 --- a/event.c Tue Aug 01 12:39:14 2006 +0200 1.2 +++ b/event.c Tue Aug 01 12:41:38 2006 +0200 1.3 @@ -57,6 +57,9 @@ 1.4 { MODKEY|ShiftMask, XK_w, spawn, { .argv = browse } }, 1.5 }; 1.6 1.7 +#define NumLockMask Mod2Mask 1.8 +unsigned int valid_mask = 255 & ~( NumLockMask | LockMask); 1.9 + 1.10 /* END CUSTOMIZE */ 1.11 1.12 /* static */ 1.13 @@ -271,10 +274,11 @@ 1.14 unsigned int i; 1.15 KeySym keysym; 1.16 XKeyEvent *ev = &e->xkey; 1.17 + ev->state &= valid_mask; 1.18 1.19 keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0); 1.20 for(i = 0; i < len; i++) 1.21 - if((keysym == key[i].keysym) && (key[i].mod == ev->state)) { 1.22 + if((keysym == key[i].keysym) && ((key[i].mod & valid_mask) == ev->state)) { 1.23 if(key[i].func) 1.24 key[i].func(&key[i].arg); 1.25 return; 1.26 @@ -377,7 +381,19 @@ 1.27 for(i = 0; i < len; i++) { 1.28 code = XKeysymToKeycode(dpy, key[i].keysym); 1.29 XUngrabKey(dpy, code, key[i].mod, root); 1.30 + if (NumLockMask) 1.31 + { 1.32 + XUngrabKey(dpy, code, key[i].mod | NumLockMask, root); 1.33 + XUngrabKey(dpy, code, key[i].mod | NumLockMask | LockMask, root); 1.34 + } 1.35 XGrabKey(dpy, code, key[i].mod, root, True, 1.36 GrabModeAsync, GrabModeAsync); 1.37 + if (NumLockMask) 1.38 + { 1.39 + XGrabKey(dpy, code, key[i].mod | NumLockMask, root, True, 1.40 + GrabModeAsync, GrabModeAsync); 1.41 + XGrabKey(dpy, code, key[i].mod | NumLockMask | LockMask, root, True, 1.42 + GrabModeAsync, GrabModeAsync); 1.43 + } 1.44 } 1.45 }