]> Dogcows Code - chaz/openbox/blobdiff - openbox/event.c
change in how things are ungrabbed to avoid grabwhilenotify. don't ungrab every key...
[chaz/openbox] / openbox / event.c
index 6e11f82eac819dcf8fff9addb8c10e8f27c723fd..e7ef27fb3058b1ab7ca6942c3a582463cde39d32 100644 (file)
@@ -539,13 +539,6 @@ static void event_process(const XEvent *ec, gpointer data)
         gboolean nomove = FALSE;
         XEvent ce;
 
-        if (client) {
-            frame_adjust_focus(client->frame, FALSE);
-            /* focus_set_client(NULL) has already been called in this
-               section or by focus_fallback */
-            client_calc_layer(client);
-        }
-
         /* Look for the followup FocusIn */
         if (!XCheckIfEvent(ob_display, &ce, event_look_for_focusin, NULL)) {
             /* There is no FocusIn, this means focus went to a window that
@@ -581,6 +574,13 @@ static void event_process(const XEvent *ec, gpointer data)
                 focus_fallback(TRUE);
             }
         }
+
+        if (client && client != focus_client) {
+            frame_adjust_focus(client->frame, FALSE);
+            /* focus_set_client(NULL) has already been called in this
+               section or by focus_fallback */
+            client_calc_layer(client);
+        }
     } else if (timewinclients)
         event_handle_user_time_window_clients(timewinclients, e);
     else if (client)
@@ -1588,8 +1588,8 @@ static gboolean event_handle_menu_keyboard(XEvent *ev)
         menu_frame_select_next(frame);
     }
 
-    /* keyboard accelerator shortcuts. */
-    else if (ev->xkey.state == 0 &&
+    /* keyboard accelerator shortcuts. (allow controlmask) */
+    else if ((ev->xkey.state & ~ControlMask) == 0 &&
              /* was it a valid key? */
              unikey != 0 &&
              /* don't bother if the menu is empty. */
@@ -1837,6 +1837,25 @@ static gboolean is_enter_focus_event_ignored(XEvent *e)
     return FALSE;
 }
 
+void event_cancel_all_key_grabs()
+{
+    if (keyboard_interactively_grabbed())
+        keyboard_interactive_cancel();
+    else if (menu_frame_visible)
+        menu_frame_hide_all();
+    else if (grab_on_keyboard())
+        ungrab_keyboard();
+    else
+        /* If we don't have the keyboard grabbed, then ungrab it with
+           XUngrabKeyboard, so that there is not a passive grab left
+           on from the KeyPress. If the grab is left on, and focus
+           moves during that time, it will be NotifyWhileGrabbed, and
+           applications like to ignore those! */
+        if (!keyboard_interactively_grabbed())
+            XUngrabKeyboard(ob_display, CurrentTime);
+
+}
+
 gboolean event_time_after(Time t1, Time t2)
 {
     g_assert(t1 != CurrentTime);
This page took 0.026347 seconds and 4 git commands to generate.