Simplify grabkeys() function

This commit is contained in:
Julien Danjou 2008-03-06 09:07:33 +01:00
parent c1b503af1a
commit edb865a070
1 changed files with 12 additions and 9 deletions

21
event.c
View File

@ -480,17 +480,20 @@ void
grabkeys(int phys_screen) grabkeys(int phys_screen)
{ {
Key *k; Key *k;
KeyCode code;
XUngrabKey(globalconf.display, AnyKey, AnyModifier, RootWindow(globalconf.display, phys_screen)); XUngrabKey(globalconf.display, AnyKey, AnyModifier, RootWindow(globalconf.display, phys_screen));
for(k = globalconf.keys; k; k = k->next) for(k = globalconf.keys; k; k = k->next)
{ if(k->keycode)
if((code = k->keycode) == 0) {
continue; XGrabKey(globalconf.display, k->keycode, k->mod,
XGrabKey(globalconf.display, code, k->mod, RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync); RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
XGrabKey(globalconf.display, code, k->mod | LockMask, RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync); XGrabKey(globalconf.display, k->keycode, k->mod | LockMask,
XGrabKey(globalconf.display, code, k->mod | globalconf.numlockmask, RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync); RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
XGrabKey(globalconf.display, code, k->mod | globalconf.numlockmask | LockMask, RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync); XGrabKey(globalconf.display, k->keycode, k->mod | globalconf.numlockmask,
} RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
XGrabKey(globalconf.display, k->keycode, k->mod | globalconf.numlockmask | LockMask,
RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
}
} }
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80