Merge branch 'backport' into work
[dana/openbox.git] / openbox / focus.c
index 8b4b66e..20b799f 100644 (file)
@@ -90,6 +90,9 @@ void focus_set_client(ObClient *client)
         push_to_top(client);
         /* remove hiliting from the window when it gets focused */
         client_hilite(client, FALSE);
+
+        /* make sure the focus cycle popup shows things in the right order */
+        focus_cycle_reorder();
     }
 
     /* set the NET_ACTIVE_WINDOW hint, but preserve it on shutdown */
@@ -199,7 +202,7 @@ void focus_order_add_new(ObClient *c)
         focus_order_to_top(c);
     else {
         g_assert(!g_list_find(focus_order, c));
-        /* if there are any iconic windows, put this above them in the order,
+        /* if there are only iconic windows, put this above them in the order,
            but if there are not, then put it under the currently focused one */
         if (focus_order && ((ObClient*)focus_order->data)->iconic)
             focus_order = g_list_insert(focus_order, c, 0);
@@ -207,16 +210,20 @@ void focus_order_add_new(ObClient *c)
             focus_order = g_list_insert(focus_order, c, 1);
     }
 
-    /* in the middle of cycling..? kill it. */
-    focus_cycle_stop(c);
+    focus_cycle_addremove(c, TRUE);
 }
 
 void focus_order_remove(ObClient *c)
 {
     focus_order = g_list_remove(focus_order, c);
 
-    /* in the middle of cycling..? kill it. */
-    focus_cycle_stop(c);
+    focus_cycle_addremove(c, TRUE);
+}
+
+void focus_order_like_new(struct _ObClient *c)
+{
+    focus_order = g_list_remove(focus_order, c);
+    focus_order_add_new(c);
 }
 
 void focus_order_to_top(ObClient *c)
@@ -232,6 +239,8 @@ void focus_order_to_top(ObClient *c)
              it && !((ObClient*)it->data)->iconic; it = g_list_next(it));
         focus_order = g_list_insert_before(focus_order, it, c);
     }
+
+    focus_cycle_reorder();
 }
 
 void focus_order_to_bottom(ObClient *c)
@@ -247,6 +256,8 @@ void focus_order_to_bottom(ObClient *c)
              it && !((ObClient*)it->data)->iconic; it = g_list_next(it));
         focus_order = g_list_insert_before(focus_order, it, c);
     }
+
+    focus_cycle_reorder();
 }
 
 ObClient *focus_order_find_first(guint desktop)
@@ -294,8 +305,15 @@ gboolean focus_valid_target(ObClient *ft,
                             gboolean desktop_windows,
                             gboolean user_request)
 {
+    /* NOTE: if any of these things change on a client, then they should call
+       focus_cycle_addremove() to make sure the client is not shown/hidden
+       when it should not be */
+
     gboolean ok = FALSE;
 
+    /* see if the window is still managed or is going away */
+    if (!ft->managed) return FALSE;
+
     /* it's on this desktop unless you want all desktops.
 
        do this check first because it will usually filter out the most