]> git.sur5r.net Git - i3/i3/blobdiff - src/con.c
Added 'con_is_hidden' to check whether a given container is visible to the user assum...
[i3/i3] / src / con.c
index aefe756ccddd831dc7c59a39393491e32d382ff5..05f608bd0e9299ce7e6e7adc7ae0af4581c1351f 100644 (file)
--- 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).