]> Dogcows Code - chaz/openbox/blobdiff - openbox/stacking.c
fallback to transients' parents when possible.
[chaz/openbox] / openbox / stacking.c
index be6d07d6daaa0d0a590da95eb97c5ebb18d0615b..275cd572bc1395b7f55535da60dac167bae30669 100644 (file)
@@ -2,6 +2,7 @@
 #include "prop.h"
 #include "focus.h"
 #include "client.h"
+#include "group.h"
 #include "frame.h"
 #include <glib.h>
 
@@ -13,12 +14,18 @@ void stacking_set_list()
     GList *it;
     guint size = g_list_length(stacking_list);
 
+    /* on shutdown, don't update the properties, so that we can read it back
+       in on startup and re-stack the windows as they were before we shut down
+    */
+    if (ob_state == State_Exiting) return;
+
     /* create an array of the window ids (from bottom to top,
        reverse order!) */
     if (size > 0) {
        windows = g_new(Window, size);
        win_it = windows;
-       for (it = g_list_last(stacking_list); it != NULL; it = it->prev, ++win_it)
+       for (it = g_list_last(stacking_list); it != NULL;
+             it = it->prev, ++win_it)
            *win_it = ((Client*)it->data)->window;
     } else
        windows = NULL;
@@ -79,12 +86,27 @@ void stacking_lower(Client *client)
 
     g_assert(stacking_list != NULL); /* this would be bad */
 
-    it = g_list_last(stacking_list);
-
     if (client->modal && client->transient_for) {
-       /* don't let a modal window lower below its transient_for */
-       it = g_list_find(stacking_list, client->transient_for);
-       g_assert(it != NULL);
+        if (client->transient_for == TRAN_GROUP) {
+            /* don't let a modal of the group lower below any other windows
+               in the group */
+            for (it = stacking_list; it; it = it->next) {
+                GSList *sit;
+                Client *c = it->data;
+
+                if (it->data == client) continue;
+
+                for (sit = c->group->members; sit; sit = sit->next)
+                    if (sit->data == it->data) break;
+                if (sit) break; /* got it */
+            }
+            if (it == NULL)
+                goto lower_no_parent;
+        } else {
+            /* don't let a modal window lower below its transient_for */
+            it = g_list_find(stacking_list, client->transient_for);
+        }
+        g_assert(it != NULL);
 
        wins[0] = (it == stacking_list ? focus_backup :
                   ((Client*)it->prev->data)->frame->window);
@@ -94,9 +116,13 @@ void stacking_lower(Client *client)
        stacking_list = g_list_remove(stacking_list, client);
        stacking_list = g_list_insert_before(stacking_list, it, client);
     } else {
+    lower_no_parent:
+
+        it = g_list_last(stacking_list);
+
        while (it != stacking_list) {
            Client *c = it->data;
-           if (client->layer >= c->layer)
+           if (client->layer <= c->layer)
                break;
            it = it->prev;
        }
This page took 0.021342 seconds and 4 git commands to generate.