+ 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));
+ }
+ } else {
+ if (!sel_child) {
+ modals = g_list_concat(modals,
+ pick_windows(c, selected, raise));
+ } else {
+ modal_sel = g_list_concat(modal_sel,
+ pick_windows(c, 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;
+ }
+ }