diff --git a/calmwm.h b/calmwm.h index 72aa1e0..33b4949 100644 --- a/calmwm.h +++ b/calmwm.h @@ -384,7 +384,7 @@ void xev_register(struct xevent *); void xev_loop(void); int xu_ptr_grab(Window, int, Cursor); -int xu_btn_grab(Window, int, u_int); +void xu_btn_grab(Window, int, u_int); int xu_ptr_regrab(int, Cursor); void xu_btn_ungrab(Window, int, u_int); void xu_ptr_ungrab(void); diff --git a/conf.c b/conf.c index f05390c..1767d14 100644 --- a/conf.c +++ b/conf.c @@ -323,14 +323,6 @@ conf_bindname(struct conf *c, char *name, char *binding) strchr(name, 'M') < strchr(name, '-')) current_binding->modmask |= Mod1Mask; - if (strchr(name, '2') != NULL && - strchr(name, '2') < strchr(name, '-')) - current_binding->modmask |= Mod2Mask; - - if (strchr(name, '3') != NULL && - strchr(name, '3') < strchr(name, '-')) - current_binding->modmask |= Mod3Mask; - if (strchr(name, '4') != NULL && strchr(name, '4') < strchr(name, '-')) current_binding->modmask |= Mod4Mask; diff --git a/cwmrc.5 b/cwmrc.5 index 10be912..c19efad 100644 --- a/cwmrc.5 +++ b/cwmrc.5 @@ -15,7 +15,7 @@ .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" .\" The following requests are required for all man pages. -.Dd $Mdocdate: June 13 2008 $ +.Dd $Mdocdate: June 14 2008 $ .Dt CWMRC 5 .Os .Sh NAME @@ -57,10 +57,6 @@ The Control key. The Meta key. .It S The Shift key. -.It 2 -The Mod2 key. -.It 3 -The Mod3 key. .It 4 The Mod4 key (normally the windows key). .El diff --git a/xevents.c b/xevents.c index dc3ac87..b4f068c 100644 --- a/xevents.c +++ b/xevents.c @@ -228,6 +228,9 @@ xev_handle_buttonpress(struct xevent *xev, XEvent *ee) cc = client_find(e->window); + /* Ignore caps lock and numlock */ + e->state &= ~(Mod2Mask | LockMask); + TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) { if (e->button == mb->button && e->state == mb->modmask) break; @@ -273,6 +276,9 @@ xev_handle_keypress(struct xevent *xev, XEvent *ee) keysym = XKeycodeToKeysym(X_Dpy, e->keycode, 0); skeysym = XKeycodeToKeysym(X_Dpy, e->keycode, 1); + /* we don't care about caps lock and numlock here */ + e->state &= ~(LockMask | Mod2Mask); + TAILQ_FOREACH(kb, &Conf.keybindingq, entry) { if (keysym != kb->keysym && skeysym == kb->keysym) modshift = ShiftMask; diff --git a/xutil.c b/xutil.c index 09c6eda..0c60fa6 100644 --- a/xutil.c +++ b/xutil.c @@ -21,6 +21,8 @@ #include "headers.h" #include "calmwm.h" +unsigned int ign_mods[] = { 0, LockMask, Mod2Mask, Mod2Mask | LockMask }; + int xu_ptr_grab(Window win, int mask, Cursor curs) { @@ -42,18 +44,22 @@ xu_ptr_ungrab(void) XUngrabPointer(X_Dpy, CurrentTime); } -int +void xu_btn_grab(Window win, int mask, u_int btn) { - return (XGrabButton(X_Dpy, btn, mask, win, - False, ButtonMask, GrabModeAsync, - GrabModeSync, None, None) == GrabSuccess ? 0 : -1); + int i; + for (i = 0; i < sizeof(ign_mods)/sizeof(*ign_mods); i++) + XGrabButton(X_Dpy, btn, (mask | ign_mods[i]), win, + False, ButtonMask, GrabModeAsync, + GrabModeSync, None, None); } void xu_btn_ungrab(Window win, int mask, u_int btn) { - XUngrabButton(X_Dpy, btn, mask, win); + int i; + for (i = 0; i < sizeof(ign_mods)/sizeof(*ign_mods); i++) + XUngrabButton(X_Dpy, btn, (mask | ign_mods[i]), win); } void @@ -75,15 +81,18 @@ xu_ptr_setpos(Window win, int x, int y) void xu_key_grab(Window win, int mask, int keysym) { - KeyCode code; + KeyCode code; + int i; code = XKeysymToKeycode(X_Dpy, keysym); if ((XKeycodeToKeysym(X_Dpy, code, 0) != keysym) && (XKeycodeToKeysym(X_Dpy, code, 1) == keysym)) mask |= ShiftMask; - XGrabKey(X_Dpy, XKeysymToKeycode(X_Dpy, keysym), mask, win, True, - GrabModeAsync, GrabModeAsync); + for (i = 0; i < sizeof(ign_mods)/sizeof(*ign_mods); i++) + XGrabKey(X_Dpy, XKeysymToKeycode(X_Dpy, keysym), + (mask | ign_mods[i]), win, True, GrabModeAsync, + GrabModeAsync); } void