aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/container.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r--sway/tree/container.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index d3931612..a83c0f6b 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -108,3 +108,16 @@ swayc_t *new_view(swayc_t *sibling, struct sway_view *sway_view) {
108 } 108 }
109 return swayc; 109 return swayc;
110} 110}
111
112swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types type) {
113 if (!sway_assert(container, "container is NULL")) {
114 return NULL;
115 }
116 if (!sway_assert(type < C_TYPES && type >= C_ROOT, "invalid type")) {
117 return NULL;
118 }
119 do {
120 container = container->parent;
121 } while (container && container->type != type);
122 return container;
123}