From d12482e5fd08403ce0954318e2993b2fb7214c8e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ingo=20B=C3=BCrk?= Date: Thu, 16 Apr 2015 19:42:31 +0200 Subject: [PATCH] Added 'con_is_hidden' to check whether a given container is visible to the user assuming its workspace is visible. This is useful for determining whether we want to set the _NET_WM_STATE_HIDDEN atom on the window. --- include/con.h | 9 ++++++++- src/con.c | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/include/con.h b/include/con.h index 498fcbaa..4813b776 100644 --- a/include/con.h +++ b/include/con.h @@ -42,12 +42,19 @@ bool con_is_leaf(Con *con); */ bool con_has_managed_window(Con *con); -/* +/** * Returns true if a container should be considered split. * */ bool con_is_split(Con *con); +/** + * This will only return true for containers which have some parent with + * a tabbed / stacked parent of which they are not the currently focused child. + * + */ +bool con_is_hidden(Con *con); + /** * Returns true if this node has regular or floating children. * diff --git a/src/con.c b/src/con.c index aefe756c..05f608bd 100644 --- a/src/con.c +++ b/src/con.c @@ -260,6 +260,29 @@ bool con_is_split(Con *con) { } } +/* + * This will only return true for containers which have some parent with + * a tabbed / stacked parent of which they are not the currently focused child. + * + */ +bool con_is_hidden(Con *con) { + Con *current = con; + + /* ascend to the workspace level and memorize the highest-up container + * which is stacked or tabbed. */ + while (current != NULL && current->type != CT_WORKSPACE) { + Con *parent = current->parent; + if (parent != NULL && (parent->layout == L_TABBED || parent->layout == L_STACKED)) { + if (TAILQ_FIRST(&(parent->focus_head)) != current) + return true; + } + + current = parent; + } + + return false; +} + /* * Returns true if this node accepts a window (if the node swallows windows, * it might already have swallowed enough and cannot hold any more). -- 2.39.5