]> Dogcows Code - chaz/openbox/commitdiff
oh, 2 things in this commit..
authorDana Jansens <danakj@orodu.net>
Wed, 14 Mar 2007 15:51:21 +0000 (15:51 +0000)
committerDana Jansens <danakj@orodu.net>
Wed, 14 Mar 2007 15:51:21 +0000 (15:51 +0000)
1) THIS ONE IS IMPORTANT: don't set client->iconfied if the window is not actually going to be allowed to iconify. heh!

2) changes to focus fallback to avoid crashing and to avoid losing focus all at the same time.

openbox/action.c
openbox/client.c
openbox/client.h
openbox/event.c
openbox/focus.c
openbox/focus.h
openbox/openbox.c
openbox/screen.c

index 6d455f1f6d3a38a0e55e5eccede066ca37314aad..73524ae4e0019af4cecabf7a0a5e73d3cb42fdf1 100644 (file)
@@ -1172,7 +1172,7 @@ void action_focus(union ActionData *data)
 void action_unfocus (union ActionData *data)
 {
     if (data->client.any.c == focus_client)
-        focus_fallback(OB_FOCUS_FALLBACK_UNFOCUSING);
+        focus_fallback(FALSE);
 }
 
 void action_iconify(union ActionData *data)
index e7c7f62acdd91d477673f1af534d9585f7e59b3d..b49d3ff8654e111027b9cd31e5a1dc5b1d999007 100644 (file)
@@ -78,6 +78,7 @@ static void client_apply_startup_state(ObClient *self, gint x, gint y);
 static void client_restore_session_state(ObClient *self);
 static void client_restore_session_stacking(ObClient *self);
 static ObAppSettings *client_get_settings_state(ObClient *self);
+static void client_unfocus(ObClient *self);
 
 void client_startup(gboolean reconfig)
 {
@@ -2515,10 +2516,10 @@ static void client_iconify_recursive(ObClient *self,
         ob_debug("%sconifying window: 0x%lx\n", (iconic ? "I" : "Uni"),
                  self->window);
 
-        self->iconic = iconic;
-
         if (iconic) {
             if (self->functions & OB_CLIENT_FUNC_ICONIFY) {
+                self->iconic = iconic;
+
                 /* update the focus lists.. iconic windows go to the bottom of
                    the list, put the new iconic window at the 'top of the
                    bottom'. */
@@ -2527,6 +2528,8 @@ static void client_iconify_recursive(ObClient *self,
                 changed = TRUE;
             }
         } else {
+            self->iconic = iconic;
+
             if (curdesk)
                 client_set_desktop(self, screen_desktop, FALSE);
 
@@ -3031,14 +3034,7 @@ gboolean client_focus(ObClient *self)
     ob_debug("Focusing client \"%s\" at time %u\n", self->title, event_curtime);
 
     if (self->can_focus) {
-        /* RevertToPointerRoot causes much more headache than RevertToNone, so
-           I choose to use it always, hopefully to find errors quicker, if any
-           are left. (I hate X. I hate focus events.)
-           
-           Update: Changing this to RevertToNone fixed a bug with mozilla (bug
-           #799. So now it is RevertToNone again.
-        */
-        XSetInputFocus(ob_display, self->window, RevertToNone,
+        XSetInputFocus(ob_display, self->window, RevertToPointerRoot,
                        event_curtime);
     }
 
@@ -3073,13 +3069,13 @@ gboolean client_focus(ObClient *self)
 /* Used when the current client is closed or otherwise hidden, focus_last will
    then prevent focus from going to the mouse pointer
 */
-void client_unfocus(ObClient *self)
+static void client_unfocus(ObClient *self)
 {
     if (focus_client == self) {
 #ifdef DEBUG_FOCUS
         ob_debug("client_unfocus for %lx\n", self->window);
 #endif
-        focus_fallback(OB_FOCUS_FALLBACK_CLOSED);
+        focus_fallback(FALSE);
     }
 }
 
index 38480a662fd0ae50b645a2c9e178f8c63e6314d4..cbb80ede6af41f0c86e9d27382f761fbf6e2caa8 100644 (file)
@@ -494,9 +494,6 @@ gboolean client_can_focus(ObClient *self);
 */
 gboolean client_focus(ObClient *self);
 
-/*! Remove focus from the client window */
-void client_unfocus(ObClient *self);
-
 /*! Activates the client for use, focusing, uniconifying it, etc. To be used
   when the user deliberately selects a window for use.
   @param here If true, then the client is brought to the current desktop;
index 7eef80174ad14a2084c4b60597294ec0c11682bc..d4d921efd229cb34d94af6b23cfcaaf9db8a4513 100644 (file)
@@ -422,7 +422,7 @@ static void event_process(const XEvent *ec, gpointer data)
             }
         }
 
-#if 0 /* focus debugging stuff */
+#if 1 /* focus debugging stuff */
     if (e->type == FocusIn || e->type == FocusOut) {
         gint mode = e->xfocus.mode;
         gint detail = e->xfocus.detail;
@@ -655,8 +655,12 @@ static void event_handle_client(ObClient *client, XEvent *e)
     case FocusOut:
         /* Look for the followup FocusIn */
         if (!XCheckIfEvent(ob_display, &ce, look_for_focusin, NULL)) {
-            /* There is no FocusIn, move focus where we can still hear events*/
-            focus_fallback(OB_FOCUS_FALLBACK_NOFOCUS);
+            /* There is no FocusIn, this means focus went to a window that
+               is not being managed. most likely, this went to PointerRoot
+               or None, meaning the window is no longer around so fallback
+               focus, but not to that window */
+            ob_debug("Focus went to a black hole !\n");
+            focus_fallback(FALSE);
         } else if (ce.xany.window == e->xany.window) {
             /* If focus didn't actually move anywhere, there is nothing to do*/
             break;
@@ -667,7 +671,9 @@ static void event_handle_client(ObClient *client, XEvent *e)
             if (ed.ignored) {
                 /* The FocusIn was ignored, this means it was on a window
                    that isn't a client. */
-                focus_fallback(OB_FOCUS_FALLBACK_NOFOCUS);
+                ob_debug("Focus went to an unmanaged window 0x%x !\n",
+                         ce.xfocus.window);
+                focus_fallback(TRUE);
             }
         }
 
index 201a43492bf88103c26c5f152d92e7becd0040c0..3fba876bf1fce4d03f4ec488f07d995fd1454d32 100644 (file)
@@ -248,7 +248,7 @@ static ObClient* focus_fallback_transient(ObClient *top, ObClient *old)
         return NULL;
 }
 
-ObClient* focus_fallback_target(ObFocusFallbackType type)
+ObClient* focus_fallback_target(gboolean allow_refocus)
 {
     GList *it;
     ObClient *old;
@@ -256,60 +256,57 @@ ObClient* focus_fallback_target(ObFocusFallbackType type)
 
     old = focus_client;
 
-    if ((type == OB_FOCUS_FALLBACK_UNFOCUSING
-         || type == OB_FOCUS_FALLBACK_CLOSED) && old) {
-        if (old->transient_for) {
-            gboolean trans = FALSE;
-
-            if (!config_focus_follow || config_focus_last)
-                trans = TRUE;
-            else if ((target = client_under_pointer()) &&
-                     client_search_transient
-                     (client_search_top_parent(target), old))
-                trans = TRUE;
-
-            /* try for transient relations */
-            if (trans) {
-                if (old->transient_for == OB_TRAN_GROUP) {
-                    for (it = focus_order[screen_desktop]; it;
-                         it = g_list_next(it))
+    if (!allow_refocus && old && old->transient_for) {
+        gboolean trans = FALSE;
+
+        if (!config_focus_follow || config_focus_last)
+            trans = TRUE;
+        else if ((target = client_under_pointer()) &&
+                 client_search_transient
+                 (client_search_top_parent(target), old))
+            trans = TRUE;
+
+        /* try for transient relations */
+        if (trans) {
+            if (old->transient_for == OB_TRAN_GROUP) {
+                for (it = focus_order[screen_desktop]; it;
+                     it = g_list_next(it))
+                {
+                    GSList *sit;
+
+                    for (sit = old->group->members; sit;
+                         sit = g_slist_next(sit))
                     {
-                        GSList *sit;
-
-                        for (sit = old->group->members; sit;
-                             sit = g_slist_next(sit))
-                        {
-                            if (sit->data == it->data)
-                                if ((target =
-                                     focus_fallback_transient(sit->data, old)))
-                                {
-                                    ob_debug("found in transient #1\n");
-                                    return target;
-                                }
-                        }
-                    }
-                } else {
-                    if ((target =
-                         focus_fallback_transient(old->transient_for, old)))
-                    {
-                        ob_debug("found in transient #2\n");
-                        return target;
+                        if (sit->data == it->data)
+                            if ((target =
+                                 focus_fallback_transient(sit->data, old)))
+                            {
+                                ob_debug("found in transient #1\n");
+                                return target;
+                            }
                     }
                 }
+            } else {
+                if ((target =
+                     focus_fallback_transient(old->transient_for, old)))
+                {
+                    ob_debug("found in transient #2\n");
+                    return target;
+                }
             }
         }
     }
 
     ob_debug("trying pointer stuff\n");
-    if (config_focus_follow &&
-        (type == OB_FOCUS_FALLBACK_UNFOCUSING || !config_focus_last))
+    if (config_focus_follow && !config_focus_last)
     {
         if ((target = client_under_pointer()))
-            if (client_normal(target) && client_can_focus(target) &&
-                client_validate(target)) {
-                ob_debug("found in pointer stuff\n");
-                return target;
-            }
+            if (allow_refocus || target != old)
+                if (client_normal(target) && client_can_focus(target) &&
+                    client_validate(target)) {
+                    ob_debug("found in pointer stuff\n");
+                    return target;
+                }
     }
 
 #if 0
@@ -328,7 +325,7 @@ ObClient* focus_fallback_target(ObFocusFallbackType type)
 
     ob_debug("trying  the focus order\n");
     for (it = focus_order[screen_desktop]; it; it = g_list_next(it))
-        if (type != OB_FOCUS_FALLBACK_UNFOCUSING || it->data != old)
+        if (allow_refocus || it->data != old)
             if (client_normal(it->data) && client_can_focus(it->data) &&
                 client_validate(it->data))
             {
@@ -344,7 +341,7 @@ ObClient* focus_fallback_target(ObFocusFallbackType type)
     return NULL;
 }
 
-void focus_fallback(ObFocusFallbackType type)
+void focus_fallback(gboolean allow_refocus)
 {
     ObClient *new;
 
@@ -354,7 +351,7 @@ void focus_fallback(ObFocusFallbackType type)
     */
     focus_set_client(NULL);
 
-    if ((new = focus_fallback_target(type)))
+    if ((new = focus_fallback_target(allow_refocus)))
         client_focus(new);
 }
 
index 81cd5ffef92c82d1d75d3b351a41f0432cf51ac6..e71cd2d7978cf67ed66fe83d4d962e4644c1a11b 100644 (file)
@@ -50,17 +50,10 @@ void focus_shutdown(gboolean reconfig);
   send focus anywhere, its called by the Focus event handlers */
 void focus_set_client(struct _ObClient *client);
 
-typedef enum {
-    OB_FOCUS_FALLBACK_UNFOCUSING, /*!< forcefully remove focus from the
-                                    current window */
-    OB_FOCUS_FALLBACK_CLOSED,     /*!< closed the window with focus */
-    OB_FOCUS_FALLBACK_NOFOCUS     /*!< nothing has focus for some reason */
-} ObFocusFallbackType;
-
-struct _ObClient* focus_fallback_target(ObFocusFallbackType type);
+struct _ObClient* focus_fallback_target(gboolean allow_refocus);
 
 /*! Call this when you need to focus something! */
-void focus_fallback(ObFocusFallbackType type);
+void focus_fallback(gboolean allow_refocus);
 
 /*! Cycle focus amongst windows. */
 void focus_cycle(gboolean forward, gboolean linear, gboolean interactive,
index 8d491a4244a590ad4b0ea359296f27d1f6e0bf00..c355747fb8054a919bf9a2c20fb6f3695106be67 100644 (file)
@@ -278,7 +278,7 @@ gint main(gint argc, gchar **argv)
             if (!reconfigure) {
                 /* get all the existing windows */
                 client_manage_all();
-                focus_fallback(OB_FOCUS_FALLBACK_NOFOCUS);
+                focus_fallback(TRUE);
             } else {
                 GList *it;
 
index dcb9cd132f33a02c5e7b90f7516a2e9c8bf71fc4..0d4f2fb3debe21d6a3ce9e037f48492de1fca40c 100644 (file)
@@ -463,7 +463,7 @@ void screen_set_desktop(guint num)
 
     event_ignore_queued_enters();
 
-    focus_hilite = focus_fallback_target(OB_FOCUS_FALLBACK_NOFOCUS);
+    focus_hilite = focus_fallback_target(TRUE);
     if (focus_hilite) {
         frame_adjust_focus(focus_hilite->frame, TRUE);
 
@@ -893,7 +893,7 @@ void screen_show_desktop(gboolean show)
                 client_validate(it->data) && client_focus(it->data))
                 break;
     } else {
-        focus_fallback(OB_FOCUS_FALLBACK_NOFOCUS);
+        focus_fallback(TRUE);
     }
 
     show = !!show; /* make it boolean */
This page took 0.040619 seconds and 4 git commands to generate.