- 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) {
- stacking_lower(CLIENT_AS_WINDOW(client->transient_for));
- return;
- } else {
- GSList *it;
-
- /* the check for TRAN_GROUP is to prevent an infinate loop with
- 2 transients of the same group at the head of the group's
- members list */
- for (it = client->group->members; it; it = it->next) {
- Client *c = it->data;
-
- if (c != client && c->transient_for != TRAN_GROUP)
- stacking_lower(it->data);
- }
- if (it == NULL) return;
+ Client *client;
+
+ if (!WINDOW_IS_CLIENT(window))
+ return window;
+
+ client = WINDOW_AS_CLIENT(window);
+
+ /* move up the transient chain as far as possible */
+ if (client->transient_for) {
+ if (client->transient_for != TRAN_GROUP) {
+ return top_transient(CLIENT_AS_WINDOW(client->transient_for));
+ } else {
+ GSList *it;
+
+ for (it = client->group->members; it; it = it->next) {
+ Client *c = it->data;
+
+ /* checking transient_for prevents infinate loops! */
+ if (c != client && !c->transient_for)
+ break;