From 041ac5784fa7f3da3667281e046507963d241551 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Tue, 9 Feb 2010 21:03:01 -0500 Subject: [PATCH] i learnt what xkb does with the state. use the state from keyrelease events directly, rather than query the state (which is not as accurate!) the xkb state (as opposed to the normally sent compat state) contains extra info like the keyboard group, the pointer buttons, etc. so we can just strip that stuff out. (See section 2.2.2 of the XKB proto document) --- openbox/event.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/openbox/event.c b/openbox/event.c index 2ebea6b..1803389 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -254,10 +254,6 @@ static void event_set_curtime(XEvent *e) static void event_hack_mods(XEvent *e) { -#ifdef XKB - XkbStateRec xkb_state; -#endif - switch (e->type) { case ButtonPress: case ButtonRelease: @@ -268,20 +264,14 @@ static void event_hack_mods(XEvent *e) break; case KeyRelease: #ifdef XKB - /* If XKB is present, then the modifiers are all strange from its - magic. Our X core protocol stuff won't work, so we use this to - find what the modifier state is instead. */ - if (XkbGetState(ob_display, XkbUseCoreKbd, &xkb_state) == Success) - e->xkey.state = - modkeys_only_modifier_masks(xkb_state.compat_state); - else + /* keep only the keyboard modifiers. xkb includes other things here. + (see XKBProto.pdf document: section 2.2.2) */ + e->xkey.state &= 0xf; #endif - { - e->xkey.state = modkeys_only_modifier_masks(e->xkey.state); - /* remove from the state the mask of the modifier key being - released, if it is a modifier key being released that is */ - e->xkey.state &= ~modkeys_keycode_to_mask(e->xkey.keycode); - } + e->xkey.state = modkeys_only_modifier_masks(e->xkey.state); + /* remove from the state the mask of the modifier key being + released, if it is a modifier key being released that is */ + e->xkey.state &= ~modkeys_keycode_to_mask(e->xkey.keycode); break; case MotionNotify: e->xmotion.state = modkeys_only_modifier_masks(e->xmotion.state); -- 1.9.1