- g_assert(stacking_list != NULL); /* this would be bad */
-
- if (WINDOW_IS_CLIENT(window)) {
- Client *client = WINDOW_AS_CLIENT(window);
- /* move up the transient chain as far as possible first */
- while (client->transient_for) {
- if (client->transient_for != TRAN_GROUP) {
- client = client->transient_for;
+ GList *ret = NULL;
+ GList *it, *next, *prev;
+ GSList *sit;
+ int i, n;
+ GList *modals = NULL;
+ GList *trans = NULL;
+ GList *modal_sel = NULL; /* the selected guys if modal */
+ GList *trans_sel = NULL; /* the selected guys if not */
+
+ /* remove first so we can't run into ourself */
+ if ((it = g_list_find(stacking_list, top)))
+ stacking_list = g_list_delete_link(stacking_list, it);
+ else
+ return NULL;
+
+ i = 0;
+ n = g_slist_length(top->transients);
+ 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->transients, it->data))) {
+ ObClient *c = sit->data;
+ gboolean sel_child;
+
+ ++i;
+
+ if (c == selected)
+ sel_child = TRUE;
+ else
+ sel_child = client_search_transient(c, selected) != NULL;
+
+ if (!c->modal) {
+ if (!sel_child) {
+ trans = g_list_concat(trans,
+ pick_windows(c, selected, raise));
+ } else {
+ trans_sel = g_list_concat(trans_sel,
+ pick_windows(c, selected,
+ raise));
+ }