+ /* save this position in the stacking list */
+ below = last;
+
+ /* find where to put the group transients, start from the top of list */
+ for (it = stacking_list; it; it = g_list_next(it)) {
+ /* skip past higher layers */
+ if (window_layer(it->data) > selected->layer)
+ continue;
+ /* if we reach the end of the layer (how?) then don't go further */
+ if (window_layer(it->data) < selected->layer)
+ break;
+ /* stop when we reach the first window in the group */
+ if (WINDOW_IS_CLIENT(it->data)) {
+ ObClient *c = it->data;
+ if (c->group == selected->group)
+ break;
+ }
+ /* if we don't hit any other group members, stop here because this
+ is where we are putting the selected window (and its children) */
+ if (it == below)
+ break;
+ }
+
+ /* save this position, this is the top of the group of windows between the
+ group transient ones we're restacking and the others up above that we're
+ restacking
+
+ we actually want to save 1 position _above_ that, for for loops to work
+ nicely, so move back one position in the list while saving it
+ */
+ above = it ? g_list_previous(it) : g_list_last(stacking_list);
+
+ /* put the windows inside the gap to the other windows we're stacking
+ into the restacking list, go from the bottom up so that we can use
+ g_list_prepend */
+ if (below) it = g_list_previous(below);
+ else it = g_list_last(stacking_list);
+ for (; it != above; it = next) {
+ next = g_list_previous(it);
+ wins = g_list_prepend(wins, it->data);
+ stacking_list = g_list_delete_link(stacking_list, it);
+ }
+
+ /* group transients go above the rest of the stuff acquired to now */
+ wins = g_list_concat(group_trans, wins);
+ /* group modals go on the very top */
+ wins = g_list_concat(group_modals, wins);
+
+ do_restack(wins, below);
+ g_list_free(wins);
+
+ /* lower our parents after us, so they go below us */
+ if (!raise && selected->parents) {
+ GSList *parents_copy, *sit;
+ GSList *reorder = NULL;
+
+ parents_copy = g_slist_copy(selected->parents);
+
+ /* go thru stacking list backwards so we can use g_slist_prepend */
+ for (it = g_list_last(stacking_list); it && parents_copy;
+ it = g_list_previous(it))
+ if ((sit = g_slist_find(parents_copy, it->data))) {
+ reorder = g_slist_prepend(reorder, sit->data);
+ parents_copy = g_slist_delete_link(parents_copy, sit);
+ }
+ g_assert(parents_copy == NULL);
+
+ /* call restack for each of these to lower them */
+ for (sit = reorder; sit; sit = g_slist_next(sit))
+ restack_windows(sit->data, raise);
+ }
+}
+
+void stacking_raise(ObWindow *window)
+{
+ if (WINDOW_IS_CLIENT(window)) {
+ ObClient *selected;
+ selected = WINDOW_AS_CLIENT(window);
+ restack_windows(selected, TRUE);
+ } else {
+ GList *wins;
+ wins = g_list_append(NULL, window);
+ stacking_list = g_list_remove(stacking_list, window);
+ do_raise(wins);
+ g_list_free(wins);