]> Dogcows Code - chaz/openbox/blobdiff - openbox/event.c
i learnt what xkb does with the state.
[chaz/openbox] / openbox / event.c
index 45ae101e7f5a925170efb7fb7829d5509980d15b..bd33b489e7aa7055f3337ff403532f5001c4d9bb 100644 (file)
@@ -260,10 +260,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:
@@ -274,20 +270,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(obt_display, XkbUseCoreKbd, &xkb_state) == Success)
-            e->xkey.state =
-                obt_keyboard_only_modmasks(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 = obt_keyboard_only_modmasks(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 &= ~obt_keyboard_keycode_to_modmask(e->xkey.keycode);
-        }
+        e->xkey.state = obt_keyboard_only_modmasks(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 &= ~obt_keyboard_keycode_to_modmask(e->xkey.keycode);
         break;
     case MotionNotify:
         e->xmotion.state = obt_keyboard_only_modmasks(e->xmotion.state);
@@ -719,22 +709,27 @@ static void event_process(const XEvent *ec, gpointer data)
 #endif
 
     if (e->type == ButtonPress || e->type == ButtonRelease) {
+        ObWindow *w;
+        static guint pressed = 0;
+        static Window pressed_win = None;
+
         /* If the button press was on some non-root window, or was physically
-           on the root window, then process it */
+           on the root window... */
         if (window != obt_root(ob_screen) ||
-            e->xbutton.subwindow == None)
+            e->xbutton.subwindow == None ||
+            /* ...or if it is related to the last button press we handled... */
+            pressed == e->xbutton.button ||
+            /* ...or it if it was physically on an openbox
+               internal window... */
+            ((w = window_find(e->xbutton.subwindow)) &&
+             WINDOW_IS_INTERNAL(w)))
+            /* ...then process the event, otherwise ignore it */
         {
             used = event_handle_user_input(client, e);
-        }
-        /* Otherwise only process it if it was physically on an openbox
-           internal window */
-        else {
-            ObWindow *w;
 
-            if ((w = window_find(e->xbutton.subwindow)) &&
-                WINDOW_IS_INTERNAL(w))
-            {
-                used = event_handle_user_input(client, e);
+            if (e->type == ButtonPress) {
+                pressed = e->xbutton.button;
+                pressed_win = e->xbutton.subwindow;
             }
         }
     }
This page took 0.024526 seconds and 4 git commands to generate.