diff options
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r-- | sway/tree/container.c | 13 |
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) { } return swayc; } + +swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types type) { + if (!sway_assert(container, "container is NULL")) { + return NULL; + } + if (!sway_assert(type < C_TYPES && type >= C_ROOT, "invalid type")) { + return NULL; + } + do { + container = container->parent; + } while (container && container->type != type); + return container; +} |