On 8/4/08, Johannes Hofmann <[EMAIL PROTECTED]> wrote:
> attached are two minor cleanups. The first simplifies grabkeys()
> similar to grabbuttons().

i've just realized that there is a problem with the patch: numlockmask
is modified but modifiers isn't

void
grabkeys(void) {
        unsigned int i, j;
        unsigned int modifiers[] = { 0, LockMask, numlockmask, 
numlockmask|LockMask };
        KeyCode code;
        XModifierKeymap *modmap;

        /* init modifier map */
        modmap = XGetModifierMapping(dpy);
        for(i = 0; i < 8; i++)
                for(j = 0; j < modmap->max_keypermod; j++) {
                        if(modmap->modifiermap[i * modmap->max_keypermod + j] ==
XKeysymToKeycode(dpy, XK_Num_Lock))
                                numlockmask = (1 << i);
                }
        XFreeModifiermap(modmap);

        XUngrabKey(dpy, AnyKey, AnyModifier, root);
        for(i = 0; i < LENGTH(keys); i++) {
                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);
        }
}

Reply via email to