- if (WINDOW_IS_CLIENT(window))
- low = find_lowest_transient(WINDOW_AS_CLIENT(window));
- else
- low = NULL;
- /* the stacking list is from highest to lowest */
- for (it = g_list_last(stacking_list); it; it = it->prev) {
- if (it == low || window_layer(window) < window_layer(it->data)) {
- it = it->next;
- break;
+ if (!WINDOW_IS_CLIENT(win)) {
+ ret = g_list_append(ret, win);
+ stacking_list = g_list_remove(stacking_list, win);
+ return ret;
+ }
+
+ c = WINDOW_AS_CLIENT(win);
+
+ /* remove first so we can't run into ourself */
+ stacking_list = g_list_remove(stacking_list, win);
+
+ /* add transient children in their stacking order */
+ i = 0;
+ n = g_slist_length(c->transients);
+ for (it = stacking_list; i < n && it; it = next) {
+ next = g_list_next(it);
+ if ((sit = g_slist_find(c->transients, it->data))) {
+ ++i;
+ ret = g_list_concat(ret, pick_windows(sit->data));
+ it = stacking_list;