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.
This commit is contained in:
oga 2008-06-17 23:40:33 +00:00
parent 19ba704ee3
commit 4f2d4724c9
5 changed files with 25 additions and 22 deletions

View File

@ -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);

8
conf.c
View File

@ -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;

View File

@ -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

View File

@ -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;

25
xutil.c
View File

@ -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