]> Dogcows Code - chaz/openbox/blobdiff - openbox/event.c
revert my commit of d3th, it fucked up focus badly
[chaz/openbox] / openbox / event.c
index dbb4ec68eb0b91874309d2ec4712618bf296743c..483050fa9b49498a4ee57f0e44ddcb084f095e61 100644 (file)
 #include <X11/ICE/ICElib.h>
 #endif
 
+typedef struct
+{
+    gboolean ignored;
+} ObEventData;
+
 static void event_process(const XEvent *e, gpointer data);
 static void event_handle_root(XEvent *e);
 static void event_handle_menu(XEvent *e);
@@ -289,8 +294,8 @@ static gboolean event_ignore(XEvent *e, ObClient *client)
        if (INVALID_FOCUSIN(e) ||
             client == NULL) {
 #ifdef DEBUG_FOCUS
-        ob_debug("FocusIn on %lx mode %d detail %d IGNORED\n",
-                 e->xfocus.window, e->xfocus.mode, e->xfocus.detail);
+            ob_debug("FocusIn on %lx mode %d detail %d IGNORED\n",
+                     e->xfocus.window, e->xfocus.mode, e->xfocus.detail);
 #endif
             /* says a client was not found for the event (or a valid FocusIn
                event was not found.
@@ -372,14 +377,18 @@ static gboolean event_ignore(XEvent *e, ObClient *client)
                         }
                     }
 
-                    /* once all the FocusOut's have been dealt with, if there
-                       is a FocusIn still left and it is valid, then use it */
-                    event_process(&fe, NULL);
-                    /* secret magic way of event_process telling us that no
-                       client was found for the FocusIn event. ^_^ */
-                    if (fe.xfocus.window != None) {
-                        fallback = FALSE;
-                        break;
+                    {
+                        ObEventData d;
+
+                        /* once all the FocusOut's have been dealt with, if
+                           there is a FocusIn still left and it is valid, then
+                           use it */
+                        event_process(&fe, &d);
+                        if (!d.ignored) {
+                            ob_debug("FocusIn was OK, so don't fallback\n");
+                            fallback = FALSE;
+                            break;
+                        }
                     }
                 }
             }
@@ -432,6 +441,7 @@ static void event_process(const XEvent *ec, gpointer data)
     ObDockApp *dockapp = NULL;
     ObWindow *obwin = NULL;
     XEvent ee, *e;
+    ObEventData *ed = data;
 
     /* make a copy we can mangle */
     ee = *ec;
@@ -461,8 +471,12 @@ static void event_process(const XEvent *ec, gpointer data)
 
     event_set_lasttime(e);
     event_hack_mods(e);
-    if (event_ignore(e, client))
+    if (event_ignore(e, client)) {
+        if (ed)
+            ed->ignored = TRUE;
         return;
+    } else if (ed)
+            ed->ignored = FALSE;
 
     /* deal with it in the kernel */
     if (group)
@@ -1167,6 +1181,16 @@ static void event_handle_menu(XEvent *ev)
                                             ev->xmotion.y_root)))
                 menu_frame_select(f, e);
         }
+        {
+            ObMenuFrame *a;
+
+            a = find_active_menu();
+            if (a && a != f &&
+                a->selected->entry->type != OB_MENU_ENTRY_TYPE_SUBMENU)
+            {
+                menu_frame_select(a, NULL);
+            }
+        }
         break;
     case KeyPress:
         if (ev->xkey.keycode == ob_keycode(OB_KEY_ESCAPE))
This page took 0.026572 seconds and 4 git commands to generate.