aboutsummaryrefslogtreecommitdiff
path: root/sway/tree
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2018-03-29 23:53:38 -0400
committerTony Crisci <tony@dubstepdish.com>2018-03-29 23:53:38 -0400
commit8f490d7d2dbadfe85dcf3dcd972471e86671442a (patch)
tree6f7a3121f15503a923c1ce53bf2bee368c6149a6 /sway/tree
parentdc8c9fbeb664518c76066cc28ee29452c6c30128 (diff)
Fix oversights from previous pull request
Diffstat (limited to 'sway/tree')
-rw-r--r--sway/tree/container.c21
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,
return container;
}
-void container_descendents(struct sway_container *root,
+void container_descendants(struct sway_container *root,
enum sway_container_type type,
void (*func)(struct sway_container *item, void *data), void *data) {
for (int i = 0; i < root->children->length; ++i) {
@@ -275,7 +275,7 @@ void container_descendents(struct sway_container *root,
func(item, data);
}
if (item->children && item->children->length) {
- container_descendents(item, type, func, data);
+ container_descendants(item, type, func, data);
}
}
}
@@ -400,7 +400,22 @@ struct sway_container *container_at(struct sway_container *parent,
return NULL;
}
-void container_for_each_descendent(struct sway_container *con,
+void container_for_each_descendant_dfs(struct sway_container *container,
+ void (*f)(struct sway_container *container, void *data),
+ void *data) {
+ if (container) {
+ if (container->children) {
+ for (int i = 0; i < container->children->length; ++i) {
+ struct sway_container *child =
+ container->children->items[i];
+ container_for_each_descendant_dfs(child, f, data);
+ }
+ }
+ f(container, data);
+ }
+}
+
+void container_for_each_descendant_bfs(struct sway_container *con,
void (*f)(struct sway_container *con, void *data), void *data) {
list_t *queue = get_bfs_queue();
if (!queue) {