]> Dogcows Code - chaz/openbox/blobdiff - openbox/event.c
some focus fixes. always set the new focus when we fallback or else weird states...
[chaz/openbox] / openbox / event.c
index 15a8e1281fb28db5ad1a64710efa427c4a0109d7..e431e8f40972c47fdaad81c12f26b65b8fb63d6c 100644 (file)
@@ -131,7 +131,7 @@ void event_startup(gboolean reconfig)
     IceAddConnectionWatch(ice_watch, NULL);
 #endif
 
-    client_add_destructor(focus_delay_client_dest, NULL);
+    client_add_destroy_notify(focus_delay_client_dest, NULL);
 }
 
 void event_shutdown(gboolean reconfig)
@@ -142,7 +142,7 @@ void event_shutdown(gboolean reconfig)
     IceRemoveConnectionWatch(ice_watch, NULL);
 #endif
 
-    client_remove_destructor(focus_delay_client_dest);
+    client_remove_destroy_notify(focus_delay_client_dest);
 }
 
 static Window event_get_window(XEvent *e)
@@ -307,15 +307,26 @@ static gboolean wanted_focusevent(XEvent *e, gboolean in_client_only)
                 return FALSE;
         }
 
+        /* This means focus moved to the frame window */
+        if (detail == NotifyInferior && !in_client_only)
+            return TRUE;
+
+        /* It was on a client, was it a valid one?
+           It's possible to get a FocusIn event for a client that was managed
+           but has disappeared. Don't even parse those FocusIn events.
+        */
+        {
+            ObWindow *w = g_hash_table_lookup(window_map, &e->xfocus.window);
+            if (!w || !WINDOW_IS_CLIENT(w))
+                return FALSE;
+        }
+
         /* This means focus moved from the root window to a client */
         if (detail == NotifyVirtual)
             return TRUE;
         /* This means focus moved from one client to another */
         if (detail == NotifyNonlinearVirtual)
             return TRUE;
-        /* This means focus moved to the frame window */
-        if (detail == NotifyInferior && !in_client_only)
-            return TRUE;
 
         /* Otherwise.. */
         return FALSE;
@@ -356,8 +367,7 @@ static Bool event_look_for_focusin(Display *d, XEvent *e, XPointer arg)
 
 Bool event_look_for_focusin_client(Display *d, XEvent *e, XPointer arg)
 {
-    return e->type == FocusIn && wanted_focusevent(e, TRUE) &&
-        e->xfocus.window != screen_support_win;
+    return e->type == FocusIn && wanted_focusevent(e, TRUE);
 }
 
 static void print_focusevent(XEvent *e)
@@ -470,6 +480,7 @@ static void event_process(const XEvent *ec, gpointer data)
             e->xfocus.detail == NotifyInferior)
         {
             XEvent ce;
+
             ob_debug_type(OB_DEBUG_FOCUS,
                           "Focus went to pointer root/none or to our frame "
                           "window\n");
@@ -508,7 +519,8 @@ static void event_process(const XEvent *ec, gpointer data)
                 if (!focus_left_screen)
                     focus_fallback(TRUE);
             }
-        } else if (client && client != focus_client) {
+        }
+        else if (client != focus_client) {
             focus_left_screen = FALSE;
             frame_adjust_focus(client->frame, TRUE);
             focus_set_client(client);
This page took 0.02369 seconds and 4 git commands to generate.