mirror of git://git.suckless.org/dwm
grabbuttons() and grabkeys() are now independent from prior numlockmask initialization
This commit is contained in:
parent
6411aa921b
commit
288cf78b18
54
dwm.c
54
dwm.c
|
@ -191,6 +191,7 @@ static void unmanage(Client *c);
|
||||||
static void unmapnotify(XEvent *e);
|
static void unmapnotify(XEvent *e);
|
||||||
static void updatebar(void);
|
static void updatebar(void);
|
||||||
static void updategeom(void);
|
static void updategeom(void);
|
||||||
|
static void updatenumlockmask(void);
|
||||||
static void updatesizehints(Client *c);
|
static void updatesizehints(Client *c);
|
||||||
static void updatetitle(Client *c);
|
static void updatetitle(Client *c);
|
||||||
static void updatewmhints(Client *c);
|
static void updatewmhints(Client *c);
|
||||||
|
@ -735,34 +736,27 @@ gettextprop(Window w, Atom atom, char *text, unsigned int size) {
|
||||||
|
|
||||||
void
|
void
|
||||||
grabbuttons(Client *c, Bool focused) {
|
grabbuttons(Client *c, Bool focused) {
|
||||||
unsigned int i, j;
|
updatenumlockmask();
|
||||||
unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
|
{
|
||||||
|
unsigned int i, j;
|
||||||
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
|
||||||
if(focused) {
|
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
|
||||||
for(i = 0; i < LENGTH(buttons); i++)
|
if(focused) {
|
||||||
if(buttons[i].click == ClkClientWin)
|
for(i = 0; i < LENGTH(buttons); i++)
|
||||||
for(j = 0; j < LENGTH(modifiers); j++)
|
if(buttons[i].click == ClkClientWin)
|
||||||
XGrabButton(dpy, buttons[i].button, buttons[i].mask | modifiers[j], c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
|
for(j = 0; j < LENGTH(modifiers); j++)
|
||||||
} else
|
XGrabButton(dpy, buttons[i].button, buttons[i].mask | modifiers[j], c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
|
||||||
XGrabButton(dpy, AnyButton, AnyModifier, c->win, False,
|
} else
|
||||||
BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
|
XGrabButton(dpy, AnyButton, AnyModifier, c->win, False,
|
||||||
|
BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
grabkeys(void) {
|
grabkeys(void) {
|
||||||
unsigned int i, j;
|
updatenumlockmask();
|
||||||
XModifierKeymap *modmap;
|
|
||||||
|
|
||||||
/* update 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);
|
|
||||||
|
|
||||||
{ /* grab keys */
|
{ /* grab keys */
|
||||||
|
unsigned int i, j;
|
||||||
unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
|
unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
|
||||||
KeyCode code;
|
KeyCode code;
|
||||||
|
|
||||||
|
@ -1575,6 +1569,20 @@ updategeom(void) {
|
||||||
by = showbar ? (topbar ? wy - bh : wy + wh) : -bh;
|
by = showbar ? (topbar ? wy - bh : wy + wh) : -bh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
updatenumlockmask(void) {
|
||||||
|
unsigned int i, j;
|
||||||
|
XModifierKeymap *modmap;
|
||||||
|
|
||||||
|
numlockmask = 0;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
updatesizehints(Client *c) {
|
updatesizehints(Client *c) {
|
||||||
long msize;
|
long msize;
|
||||||
|
|
Loading…
Reference in New Issue