aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/tree/container.h10
-rw-r--r--sway/criteria.c2
-rw-r--r--sway/desktop/output.c2
-rw-r--r--sway/input/seat.c2
-rw-r--r--sway/tree/container.c21
5 files changed, 29 insertions, 8 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index 16df3ee7..3bb497db 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -104,7 +104,7 @@ struct sway_container *container_view_destroy(struct sway_container *view);
104struct sway_container *container_set_layout(struct sway_container *container, 104struct sway_container *container_set_layout(struct sway_container *container,
105 enum sway_container_layout layout); 105 enum sway_container_layout layout);
106 106
107void container_descendents(struct sway_container *root, 107void container_descendants(struct sway_container *root,
108 enum sway_container_type type, 108 enum sway_container_type type,
109 void (*func)(struct sway_container *item, void *data), void *data); 109 void (*func)(struct sway_container *item, void *data), void *data);
110 110
@@ -131,7 +131,13 @@ struct sway_container *container_at(struct sway_container *parent,
131/** 131/**
132 * Apply the function for each child of the container breadth first. 132 * Apply the function for each child of the container breadth first.
133 */ 133 */
134void container_for_each_descendent(struct sway_container *container, 134void container_for_each_descendant_bfs(struct sway_container *container,
135 void (*f)(struct sway_container *container, void *data), void *data);
136
137/**
138 * Apply the function for each child of the container depth first.
139 */
140void container_for_each_descendant_dfs(struct sway_container *container,
135 void (*f)(struct sway_container *container, void *data), void *data); 141 void (*f)(struct sway_container *container, void *data), void *data);
136 142
137#endif 143#endif
diff --git a/sway/criteria.c b/sway/criteria.c
index 247f6b75..5fee1888 100644
--- a/sway/criteria.c
+++ b/sway/criteria.c
@@ -435,7 +435,7 @@ list_t *container_for_crit_tokens(list_t *tokens) {
435 struct list_tokens list_tokens = 435 struct list_tokens list_tokens =
436 (struct list_tokens){create_list(), tokens}; 436 (struct list_tokens){create_list(), tokens};
437 437
438 container_for_each_descendent(&root_container, 438 container_for_each_descendant_dfs(&root_container,
439 (void (*)(struct sway_container *, void *))container_match_add, 439 (void (*)(struct sway_container *, void *))container_match_add,
440 &list_tokens); 440 &list_tokens);
441 441
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index ba778f4c..1273df59 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -228,7 +228,7 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
228 .output = soutput, 228 .output = soutput,
229 .now = &now, 229 .now = &now,
230 }; 230 };
231 container_descendents(workspace, C_VIEW, output_frame_view, &rdata); 231 container_descendants(workspace, C_VIEW, output_frame_view, &rdata);
232 232
233 // render unmanaged views on top 233 // render unmanaged views on top
234 struct sway_view *view; 234 struct sway_view *view;
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 76d29b52..aa0b1d50 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -130,7 +130,7 @@ struct sway_seat *sway_seat_create(struct sway_input_manager *input,
130 // init the focus stack 130 // init the focus stack
131 wl_list_init(&seat->focus_stack); 131 wl_list_init(&seat->focus_stack);
132 132
133 container_for_each_descendent(&root_container, collect_focus_iter, seat); 133 container_for_each_descendant_dfs(&root_container, collect_focus_iter, seat);
134 134
135 wl_signal_add(&root_container.sway_root->events.new_container, 135 wl_signal_add(&root_container.sway_root->events.new_container,
136 &seat->new_container); 136 &seat->new_container);
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
269void container_descendents(struct sway_container *root, 269void 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
403void container_for_each_descendent(struct sway_container *con, 403void 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
418void 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) {