X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fstacking.c;h=275cd572bc1395b7f55535da60dac167bae30669;hb=00042637e8b8bef92456d96547230ec710cf6a7b;hp=081bde932bb8b0cefbc91e3a2bc4c9dac0eef10a;hpb=f8a47de5ec444c452093371e3db16857eb39a490;p=chaz%2Fopenbox diff --git a/openbox/stacking.c b/openbox/stacking.c index 081bde93..275cd572 100644 --- a/openbox/stacking.c +++ b/openbox/stacking.c @@ -2,6 +2,7 @@ #include "prop.h" #include "focus.h" #include "client.h" +#include "group.h" #include "frame.h" #include @@ -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; 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; @@ -46,7 +53,7 @@ void stacking_raise(Client *client) /* the stacking list is from highest to lowest */ it = stacking_list; - while (it) { + while (it != NULL) { Client *c = it->data; if (client->layer >= c->layer && m != c) break; @@ -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; }