From 3af6434085aee75bd90e22aee95419dc0ae0b969 Mon Sep 17 00:00:00 2001 From: "arg@10ksloc.org" Date: Wed, 2 Aug 2006 11:13:32 +0200 Subject: applied Sanders patches (numlock2) --- event.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'event.c') diff --git a/event.c b/event.c index 1aed904..0359971 100644 --- a/event.c +++ b/event.c @@ -19,7 +19,7 @@ typedef struct { KEYS -static unsigned int valid_mask = 255 & ~(NUMLOCKMASK | LockMask); +#define CLEANMASK(mask) (mask & ~(NUMLOCKMASK | LockMask)) static void movemouse(Client *c) @@ -229,11 +229,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 & valid_mask) == ev->state)) { + if(keysym == key[i].keysym && + CLEANMASK(key[i].mod) == CLEANMASK(ev->state)) { if(key[i].func) key[i].func(&key[i].arg); return; @@ -335,13 +335,20 @@ grabkeys() for(i = 0; i < len; i++) { code = XKeysymToKeycode(dpy, key[i].keysym); + /* normal */ XUngrabKey(dpy, code, key[i].mod, root); - 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); + /* capslock */ + XUngrabKey(dpy, code, key[i].mod | LockMask, root); + XGrabKey(dpy, code, key[i].mod | LockMask, root, True, + GrabModeAsync, GrabModeAsync); + /* numlock */ + XUngrabKey(dpy, code, key[i].mod | NUMLOCKMASK, root); XGrabKey(dpy, code, key[i].mod | NUMLOCKMASK, root, True, GrabModeAsync, GrabModeAsync); + /* capslock & numlock */ + XUngrabKey(dpy, code, key[i].mod | NUMLOCKMASK | LockMask, root); XGrabKey(dpy, code, key[i].mod | NUMLOCKMASK | LockMask, root, True, GrabModeAsync, GrabModeAsync); } -- cgit v1.2.3