From: Mikael Magnusson Date: Fri, 19 Feb 2010 20:53:05 +0000 (+0100) Subject: Revert "i learnt what xkb does with the state." X-Git-Url: http://git.openbox.org/?p=mikachu%2Fopenbox.git;a=commitdiff_plain;h=0f67693c08d96382d56b7fee9b2aa226bb3670d5 Revert "i learnt what xkb does with the state." But apparently not well enough This reverts commit 041ac5784fa7f3da3667281e046507963d241551. --- diff --git a/openbox/event.c b/openbox/event.c index f082cdb..f7fe030 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -254,6 +254,10 @@ 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: @@ -264,14 +268,20 @@ static void event_hack_mods(XEvent *e) break; case KeyRelease: #ifdef XKB - /* keep only the keyboard modifiers. xkb includes other things here. - (see XKBProto.pdf document: section 2.2.2) */ - e->xkey.state &= 0xf; + /* 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 #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);