diff options
-rw-r--r-- | sway/tree/container.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index f14e9b9a..bd9f9894 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -355,14 +355,15 @@ struct sway_container *container_view_create(struct sway_container *sibling, | |||
355 | void container_descendants(struct sway_container *root, | 355 | void container_descendants(struct sway_container *root, |
356 | enum sway_container_type type, | 356 | enum sway_container_type type, |
357 | void (*func)(struct sway_container *item, void *data), void *data) { | 357 | void (*func)(struct sway_container *item, void *data), void *data) { |
358 | if (!root->children || !root->children->length) { | ||
359 | return; | ||
360 | } | ||
358 | for (int i = 0; i < root->children->length; ++i) { | 361 | for (int i = 0; i < root->children->length; ++i) { |
359 | struct sway_container *item = root->children->items[i]; | 362 | struct sway_container *item = root->children->items[i]; |
360 | if (item->type == type) { | 363 | if (item->type == type) { |
361 | func(item, data); | 364 | func(item, data); |
362 | } | 365 | } |
363 | if (item->children && item->children->length) { | 366 | container_descendants(item, type, func, data); |
364 | container_descendants(item, type, func, data); | ||
365 | } | ||
366 | } | 367 | } |
367 | } | 368 | } |
368 | 369 | ||