merge r5799-5806 from trunk
authorDana Jansens <danakj@orodu.net>
Sun, 22 Apr 2007 20:43:45 +0000 (20:43 +0000)
committerDana Jansens <danakj@orodu.net>
Sun, 22 Apr 2007 20:43:45 +0000 (20:43 +0000)
openbox/event.c
openbox/focus.c
openbox/popup.c
openbox/screen.c

index c8356be1744aa1c059eb8e69b4a17c0d017b3e80..f9d5c38fe881aba5e598ca8bbab7d8e69ec777aa 100644 (file)
@@ -348,10 +348,6 @@ static gboolean wanted_focusevent(XEvent *e)
         if (detail == NotifyNonlinearVirtual)
             return TRUE;
 
-        /* This means focus reverted off of a client */
-        if (detail == NotifyInferior)
-            return TRUE;
-
         /* Otherwise.. */
         return FALSE;
     } else {
@@ -391,7 +387,12 @@ static gboolean event_ignore(XEvent *e, ObClient *client)
 {
     switch(e->type) {
     case FocusIn:
+        if (!wanted_focusevent(e))
+            return TRUE;
+        break;
     case FocusOut:
+        if (client == NULL)
+            return TRUE;
         if (!wanted_focusevent(e))
             return TRUE;
         break;
@@ -453,26 +454,10 @@ static void event_process(const XEvent *ec, gpointer data)
         /* crossing events for menu */
         event_handle_menu(e);
     } else if (e->type == FocusIn) {
-        if (e->xfocus.detail == NotifyPointerRoot ||
-                   e->xfocus.detail == NotifyDetailNone) {
-            ob_debug_type(OB_DEBUG_FOCUS, "Focus went to root\n");
-            /* Focus has been reverted to the root window or nothing
-               FocusOut events come after UnmapNotify, so we don't need to
-               worry about focusing an invalid window
-             */
-            focus_fallback(TRUE);
-        } else if (e->xfocus.detail == NotifyInferior) {
-            ob_debug_type(OB_DEBUG_FOCUS, "Focus went to parent\n");
-            /* Focus has been reverted to parent, which is our frame window,
-               or the root window
-               FocusOut events come after UnmapNotify, so we don't need to
-               worry about focusing an invalid window
-            */
-            focus_fallback(TRUE);
-        } else if (client && client != focus_client) {
+        if (client && client != focus_client) {
             frame_adjust_focus(client->frame, TRUE);
-            client_calc_layer(client);
             focus_set_client(client);
+            client_calc_layer(client);
         }
     } else if (e->type == FocusOut) {
         gboolean nomove = FALSE;
@@ -488,8 +473,18 @@ static void event_process(const XEvent *ec, gpointer data)
             /* nothing is focused */
             focus_set_client(NULL);
         } else if (ce.xany.window == e->xany.window) {
+            ob_debug_type(OB_DEBUG_FOCUS, "Focus didn't go anywhere\n");
             /* If focus didn't actually move anywhere, there is nothing to do*/
             nomove = TRUE;
+        } else if (ce.xfocus.detail == NotifyPointerRoot ||
+                   ce.xfocus.detail == NotifyDetailNone ||
+                   ce.xfocus.detail == NotifyInferior) {
+            ob_debug_type(OB_DEBUG_FOCUS, "Focus went to root\n");
+            /* Focus has been reverted to the root window or nothing
+               FocusOut events come after UnmapNotify, so we don't need to
+               worry about focusing an invalid window
+             */
+            focus_fallback(TRUE);
         } else {
             /* Focus did move, so process the FocusIn event */
             ObEventData ed = { .ignored = FALSE };
@@ -506,6 +501,7 @@ static void event_process(const XEvent *ec, gpointer data)
 
         if (client && !nomove) {
             frame_adjust_focus(client->frame, FALSE);
+            /* focus_set_client has already been called for sure */
             client_calc_layer(client);
         }
     } else if (group)
index 7a686800de9ea81d5ac01f5004107d4c49b47f22..f794e4666c245ea1a8858c6bd28d2c2d0695cc3f 100644 (file)
@@ -259,10 +259,7 @@ ObClient* focus_fallback_target(gboolean allow_refocus, ObClient *old)
 void focus_fallback(gboolean allow_refocus)
 {
     ObClient *new;
-    ObClient *old;
-
-    /* save this before moving focus away to nothing */
-    old = focus_client;
+    ObClient *old = focus_client;
 
     /* unfocus any focused clients.. they can be focused by Pointer events
        and such, and then when I try focus them, I won't get a FocusIn event
@@ -282,6 +279,8 @@ void focus_nothing()
         screen_install_colormap(NULL, TRUE);
     }
 
+    focus_client = NULL;
+
     /* when nothing will be focused, send focus to the backup target */
     XSetInputFocus(ob_display, screen_support_win, RevertToPointerRoot,
                    event_curtime);
index 031b1d49c1384b9f4fd58d587a84c5ede75261d8..88619e77f073fbf493ec96e7a741172af3277c97 100644 (file)
@@ -23,6 +23,7 @@
 #include "frame.h"
 #include "client.h"
 #include "stacking.h"
+#include "event.h"
 #include "screen.h"
 #include "render/render.h"
 #include "render/theme.h"
index a54b2b564074f771ba2bacae86b61045413ac5fe..c0569c29406eadd79027b0d7631b8fa4346e4a62 100644 (file)
@@ -460,10 +460,14 @@ void screen_set_desktop(guint num)
         }
     }
 
-    /* reduce flicker by hiliting now rather than waiting for the server
-       FocusIn event */
-    if ((c = focus_fallback_target(TRUE, focus_client)))
+    /* have to try focus here because when you leave an empty desktop
+       there is no focus out to watch for */
+    if ((c = focus_fallback_target(TRUE, focus_client))) {
+        /* reduce flicker by hiliting now rather than waiting for the server
+           FocusIn event */
         frame_adjust_focus(c->frame, TRUE);
+        client_focus(c);
+    }
 
     event_ignore_queued_enters();
 }