diff options
author | Tony Crisci <tony@dubstepdish.com> | 2018-03-29 23:53:38 -0400 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2018-03-29 23:53:38 -0400 |
commit | 8f490d7d2dbadfe85dcf3dcd972471e86671442a (patch) | |
tree | 6f7a3121f15503a923c1ce53bf2bee368c6149a6 /sway/tree/container.c | |
parent | Revert "Merge pull request #1653 from swaywm/revert-1647-refactor-tree" (diff) | |
download | sway-8f490d7d2dbadfe85dcf3dcd972471e86671442a.tar.gz sway-8f490d7d2dbadfe85dcf3dcd972471e86671442a.tar.zst sway-8f490d7d2dbadfe85dcf3dcd972471e86671442a.zip |
Fix oversights from previous pull request
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r-- | sway/tree/container.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index 40047dcf..6a6861f3 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -266,7 +266,7 @@ struct sway_container *container_set_layout(struct sway_container *container, | |||
266 | return container; | 266 | return container; |
267 | } | 267 | } |
268 | 268 | ||
269 | void container_descendents(struct sway_container *root, | 269 | void container_descendants(struct sway_container *root, |
270 | enum sway_container_type type, | 270 | enum sway_container_type type, |
271 | void (*func)(struct sway_container *item, void *data), void *data) { | 271 | void (*func)(struct sway_container *item, void *data), void *data) { |
272 | for (int i = 0; i < root->children->length; ++i) { | 272 | for (int i = 0; i < root->children->length; ++i) { |
@@ -275,7 +275,7 @@ void container_descendents(struct sway_container *root, | |||
275 | func(item, data); | 275 | func(item, data); |
276 | } | 276 | } |
277 | if (item->children && item->children->length) { | 277 | if (item->children && item->children->length) { |
278 | container_descendents(item, type, func, data); | 278 | container_descendants(item, type, func, data); |
279 | } | 279 | } |
280 | } | 280 | } |
281 | } | 281 | } |
@@ -400,7 +400,22 @@ struct sway_container *container_at(struct sway_container *parent, | |||
400 | return NULL; | 400 | return NULL; |
401 | } | 401 | } |
402 | 402 | ||
403 | void container_for_each_descendent(struct sway_container *con, | 403 | void container_for_each_descendant_dfs(struct sway_container *container, |
404 | void (*f)(struct sway_container *container, void *data), | ||
405 | void *data) { | ||
406 | if (container) { | ||
407 | if (container->children) { | ||
408 | for (int i = 0; i < container->children->length; ++i) { | ||
409 | struct sway_container *child = | ||
410 | container->children->items[i]; | ||
411 | container_for_each_descendant_dfs(child, f, data); | ||
412 | } | ||
413 | } | ||
414 | f(container, data); | ||
415 | } | ||
416 | } | ||
417 | |||
418 | void container_for_each_descendant_bfs(struct sway_container *con, | ||
404 | void (*f)(struct sway_container *con, void *data), void *data) { | 419 | void (*f)(struct sway_container *con, void *data), void *data) { |
405 | list_t *queue = get_bfs_queue(); | 420 | list_t *queue = get_bfs_queue(); |
406 | if (!queue) { | 421 | if (!queue) { |