-static GList *pick_group_windows(ObClient *top, ObClient *selected, gboolean raise)
-{
- GList *ret = NULL;
- GList *it, *next, *prev;
- GSList *sit;
- int i, n;
-
- /* add group members in their stacking order */
- if (top->group) {
- i = 0;
- n = g_slist_length(top->group->members) - 1;
- for (it = stacking_list; i < n && it; it = next) {
- prev = g_list_previous(it);
- next = g_list_next(it);
-
- if ((sit = g_slist_find(top->group->members, it->data))) {
- ++i;
- ret = g_list_concat(ret,
- pick_windows(sit->data, selected, raise));
- /* if we dont have a prev then start back at the beginning,
- otherwise skip back to the prev's next */
- next = prev ? g_list_next(prev) : stacking_list;
- }
- }
+ 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);