From 2828c4d03fecc1bf5ba81355dd02676058490844 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Fri, 8 Oct 2004 17:06:09 +0000 Subject: Improve handling of transients/modals which aren't tied to a parent window. (Old svn revision: 12044) --- src/transients.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'src/transients.c') diff --git a/src/transients.c b/src/transients.c index a8e0f8a77..56889c23d 100644 --- a/src/transients.c +++ b/src/transients.c @@ -79,6 +79,39 @@ clientIsTransientOrModal (Client * c) return (clientIsTransient(c) || clientIsModal(c)); } +gboolean +clientIsValidTransientOrModal (Client * c) +{ + g_return_val_if_fail (c != NULL, FALSE); + + TRACE ("entering clientIsValidTransientOrModal"); + if (clientIsTransientOrModalForGroup (c)) + { + ScreenInfo *screen_info = c->screen_info; + GList *index; + + /* Look for a valid transient ormodal for the same group */ + for (index = screen_info->windows_stack; index; index = g_list_next (index)) + { + Client *c2 = (Client *) index->data; + if (c2 != c) + { + if (clientIsTransientOrModalFor (c, c2)) + { + /* We found one, look no further */ + return TRUE; + } + } + } + } + else if (clientIsTransientOrModal (c)) + { + return (clientGetTransient (c) != NULL); + } + + return (FALSE); +} + gboolean clientSameGroup (Client * c1, Client * c2) { @@ -174,6 +207,38 @@ clientIsTransientOrModalForGroup (Client * c) return (clientIsTransientForGroup(c) || clientIsModalForGroup(c)); } +gboolean +clientTransientOrModalHasAncestor (Client * c, int ws) +{ + Client *c2 = NULL; + GList *index = NULL; + ScreenInfo *screen_info = NULL; + + g_return_val_if_fail (c != NULL, FALSE); + + TRACE ("entering clientTransientOrModalHasAncestor"); + + if (!clientIsTransientOrModal (c)) + { + return FALSE; + } + + screen_info = c->screen_info; + for (index = screen_info->windows_stack; index; index = g_list_next (index)) + { + c2 = (Client *) index->data; + if ((c2 != c) && !clientIsTransientOrModal (c2) + && clientIsTransientOrModalFor (c, c2) + && !FLAG_TEST (c2->flags, CLIENT_FLAG_ICONIFIED) + && (c2->win_workspace == ws)) + { + return TRUE; + } + } + return FALSE; + +} + Client * clientGetModalFor (Client * c) { -- cgit v1.2.1