X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fstacking.c;h=ebd863ea0ae96e47b36b5747b358d6901a2f618e;hb=c6945c13975b4b96463816a58f5185b4c49cdc9c;hp=139f968f3efcf957d4ea7fe9b3ab25f7e0a20541;hpb=c170d2f717559ccaab551ea2c9089438994b0c04;p=chaz%2Fopenbox diff --git a/openbox/stacking.c b/openbox/stacking.c index 139f968f..ebd863ea 100644 --- a/openbox/stacking.c +++ b/openbox/stacking.c @@ -11,9 +11,9 @@ GList *stacking_list = NULL; void stacking_set_list() { - Window *windows, *win_it; + Window *windows = NULL; GList *it; - guint size = g_list_length(stacking_list); + guint i = 0; /* 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 @@ -22,23 +22,18 @@ void stacking_set_list() /* 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) - if (WINDOW_IS_CLIENT(it->data)) { - *win_it = WINDOW_AS_CLIENT(it->data)->window; - ++win_it; - } - } else - windows = win_it = NULL; + if (stacking_list) { + windows = g_new(Window, g_list_length(stacking_list)); + for (it = g_list_last(stacking_list); it; it = g_list_previous(it)) { + if (WINDOW_IS_CLIENT(it->data)) + windows[i++] = WINDOW_AS_CLIENT(it->data)->window; + } + } PROP_SETA32(ob_root, net_client_list_stacking, window, - (guint32*)windows, win_it - windows); + (guint32*)windows, i); - if (windows) - g_free(windows); + g_free(windows); } static void do_restack(GList *wins, GList *before) @@ -66,6 +61,8 @@ static void do_restack(GList *wins, GList *before) for (i = 1, it = wins; it; ++i, it = g_list_next(it)) { win[i] = window_top(it->data); + g_assert(win[i] != None); /* better not call stacking shit before + setting your top level window value */ stacking_list = g_list_insert_before(stacking_list, before, it->data); } @@ -78,9 +75,11 @@ static void do_restack(GList *wins, GList *before) XRestackWindows(ob_display, win, i); g_free(win); + + stacking_set_list(); } -static void raise(GList *wins) +static void do_raise(GList *wins) { GList *it; GList *layer[NUM_STACKLAYER] = {NULL}; @@ -107,7 +106,7 @@ static void raise(GList *wins) } } -static void lower(GList *wins) +static void do_lower(GList *wins) { GList *it; GList *layer[NUM_STACKLAYER] = {NULL}; @@ -238,7 +237,7 @@ void stacking_raise(ObWindow *window) window = top_transient(window); wins = pick_windows(window); wins = g_list_concat(wins, pick_group_windows(window)); - raise(wins); + do_raise(wins); g_list_free(wins); } @@ -248,25 +247,23 @@ void stacking_lower(ObWindow *window) window = top_transient(window); wins = pick_windows(window); - wins = g_list_concat(wins, pick_group_windows(window)); - lower(wins); + wins = g_list_concat(pick_group_windows(window), wins); + do_lower(wins); g_list_free(wins); } void stacking_add(ObWindow *win) { StackLayer l; - GList *wins, *it; + GList *wins; + + g_assert(focus_backup != None); /* make sure I dont break this in the + future */ l = window_layer(win); wins = g_list_append(NULL, win); /* list of 1 element */ - for (it = stacking_list; it; it = g_list_next(it)) - if (window_layer(it->data) <= l) - break; - do_restack(wins, it); - g_list_free(wins); - + stacking_list = g_list_append(stacking_list, win); stacking_raise(win); }