Re: [dwm] [patch] minor cleanups

From: Szabolcs Nagy <nszabolcs_AT_gmail.com>
Date: Sun, 10 Aug 2008 12:55:39 +0200

On 8/4/08, Johannes Hofmann <Johannes.Hofmann_AT_gmx.de> 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);
        }
}
Received on Sun Aug 10 2008 - 10:55:39 UTC

This archive was generated by hypermail 2.2.0 : Sun Aug 10 2008 - 11:00:11 UTC