diff options
author | oga | 2008-06-17 23:40:33 +0000 |
---|---|---|
committer | oga | 2008-06-17 23:40:33 +0000 |
commit | e81c12ba73d4e86fe08110f8fa1fabc02745626c (patch) | |
tree | 8bf597fd72b6543daa7684421bf7f177599387e5 | |
parent | d8992dea78215e8b6fd889297b028280fd28922d (diff) | |
download | cwm-e81c12ba73d4e86fe08110f8fa1fabc02745626c.tar.gz |
Ignore caps lock and numlock for keyboard bindings. The way Xlib makes
you do this is ugly. Also remove mod2 (numlock) and mod3 (odd) from the
list of keybinding modifiers. They don't make much sense here.
based on a heavily modified diff from Martynas.
ok okan.
Diffstat (limited to '')
-rw-r--r-- | calmwm.h | 4 | ||||
-rw-r--r-- | conf.c | 10 | ||||
-rw-r--r-- | cwmrc.5 | 8 | ||||
-rw-r--r-- | xevents.c | 8 | ||||
-rw-r--r-- | xutil.c | 27 |
5 files changed, 30 insertions, 27 deletions
@@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: calmwm.h,v 1.54 2008/06/15 02:47:46 oga Exp $ + * $Id: calmwm.h,v 1.55 2008/06/17 23:40:33 oga Exp $ */ #ifndef _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); @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: conf.c,v 1.41 2008/06/16 19:09:48 mk Exp $ + * $Id: conf.c,v 1.42 2008/06/17 23:40:33 oga Exp $ */ #include "headers.h" @@ -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; @@ -1,4 +1,4 @@ -.\" $OpenBSD: cwmrc.5,v 1.9 2008/06/14 21:48:54 okan Exp $ +.\" $OpenBSD: cwmrc.5,v 1.10 2008/06/17 23:40:33 oga Exp $ .\" .\" Copyright (c) 2004,2005 Marius Aamodt Eriksen <marius@monkey.org> .\" @@ -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 14 2008 $ +.Dd $Mdocdate: June 17 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 @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: xevents.c,v 1.22 2008/06/17 20:55:48 oga Exp $ + * $Id: xevents.c,v 1.23 2008/06/17 23:40:33 oga Exp $ */ /* @@ -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; @@ -15,12 +15,14 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: xutil.c,v 1.6 2008/05/15 22:18:00 oga Exp $ + * $Id: xutil.c,v 1.7 2008/06/17 23:40:33 oga Exp $ */ #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 |