From 0aba4013e91054c94bf5a0cfaf8066f5cae94b41 Mon Sep 17 00:00:00 2001 From: Maarten Maathuis Date: Thu, 4 Dec 2008 15:16:38 +0100 Subject: [PATCH] client: Improve handling of transient windows. Signed-off-by: Maarten Maathuis Signed-off-by: Julien Danjou --- client.c | 10 ++++++---- client.h | 25 +++++++++++++++++++++---- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/client.c b/client.c index 23e0a6c31..e482e4c90 100644 --- a/client.c +++ b/client.c @@ -441,7 +441,7 @@ void client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen, int screen) { xcb_get_property_cookie_t ewmh_icon_cookie; - client_t *c, *group = NULL; + client_t *c, *tc = NULL, *group = NULL; image_t *icon; const uint32_t select_input_val[] = { @@ -486,8 +486,10 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen, property_update_wm_transient_for(c, NULL); property_update_wm_client_leader(c, NULL); - if(c->transient_for) - screen = c->transient_for->screen; + /* Recursively find the parent. */ + for(tc = c; tc->transient_for; tc = tc->transient_for); + if(tc != c) + screen = tc->screen; /* Try to load props, if it fails check for group windows. * transient_for windows are excluded, because they inherit the parent tags. */ @@ -516,7 +518,7 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen, if (!c->issticky) { if(c->transient_for) - client_duplicate_tags(c->transient_for, c); + client_duplicate_tags(tc, c); else if (group) client_duplicate_tags(group, c); else diff --git a/client.h b/client.h index 5e403c066..f9bc68ab6 100644 --- a/client.h +++ b/client.h @@ -79,9 +79,23 @@ DO_SLIST(client_t, client, client_unref) static inline void client_raise(client_t *c) { + client_t *tc = c; + int counter = 0; + + /* Find number of transient layers. */ + for(counter = 0; tc->transient_for; counter++) + tc = tc->transient_for; + + /* Push them in reverse order. */ + for(; counter > 0; counter--) + { + tc = c; + for(int i = 0; i < counter; i++) + tc = tc->transient_for; + stack_client_push(tc); + } + /* Push c on top of the stack. */ - if(c->transient_for) - stack_client_push(c->transient_for); stack_client_push(c); client_stack(); } @@ -93,8 +107,11 @@ static inline void client_lower(client_t *c) { stack_client_append(c); - if(c->transient_for) - stack_client_append(c->transient_for); + + /* Traverse all transient layers. */ + for(client_t *tc = c->transient_for; tc; tc = tc->transient_for) + stack_client_append(tc); + client_stack(); }