aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-08-11 15:57:09 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-08-11 15:57:09 +1000
commit4ad1ccc9dcd1e9090090dfbae153ded1b36af9ff (patch)
tree233e3977ad922df56a76d91e59606019fc21c38f
parentMerge pull request #2447 from ianyfan/swaynag-leak (diff)
downloadsway-4ad1ccc9dcd1e9090090dfbae153ded1b36af9ff.tar.gz
sway-4ad1ccc9dcd1e9090090dfbae153ded1b36af9ff.tar.zst
sway-4ad1ccc9dcd1e9090090dfbae153ded1b36af9ff.zip
Remove container_for_each_descendant_bfs
The function was not used. Also renames container_for_each_descendant_dfs to just container_for_each_descendant.
-rw-r--r--include/sway/tree/container.h8
-rw-r--r--sway/commands/hide_edge_borders.c2
-rw-r--r--sway/commands/show_marks.c2
-rw-r--r--sway/commands/unmark.c2
-rw-r--r--sway/config.c4
-rw-r--r--sway/criteria.c4
-rw-r--r--sway/input/seat.c3
-rw-r--r--sway/ipc-server.c2
-rw-r--r--sway/tree/container.c50
9 files changed, 15 insertions, 62 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index 4d0e6003..4170f6ba 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -239,15 +239,9 @@ struct sway_container *tiling_container_at(
239 struct wlr_surface **surface, double *sx, double *sy); 239 struct wlr_surface **surface, double *sx, double *sy);
240 240
241/** 241/**
242 * Apply the function for each descendant of the container breadth first.
243 */
244void container_for_each_descendant_bfs(struct sway_container *container,
245 void (*f)(struct sway_container *container, void *data), void *data);
246
247/**
248 * Apply the function for each child of the container depth first. 242 * Apply the function for each child of the container depth first.
249 */ 243 */
250void container_for_each_descendant_dfs(struct sway_container *container, 244void container_for_each_descendant(struct sway_container *container,
251 void (*f)(struct sway_container *container, void *data), void *data); 245 void (*f)(struct sway_container *container, void *data), void *data);
252 246
253/** 247/**
diff --git a/sway/commands/hide_edge_borders.c b/sway/commands/hide_edge_borders.c
index 7d70055b..bb390f5f 100644
--- a/sway/commands/hide_edge_borders.c
+++ b/sway/commands/hide_edge_borders.c
@@ -31,7 +31,7 @@ struct cmd_results *cmd_hide_edge_borders(int argc, char **argv) {
31 "<none|vertical|horizontal|both|smart>'"); 31 "<none|vertical|horizontal|both|smart>'");
32 } 32 }
33 33
34 container_for_each_descendant_dfs(&root_container, _configure_view, NULL); 34 container_for_each_descendant(&root_container, _configure_view, NULL);
35 35
36 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 36 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
37} 37}
diff --git a/sway/commands/show_marks.c b/sway/commands/show_marks.c
index 434a0e27..cf153a0a 100644
--- a/sway/commands/show_marks.c
+++ b/sway/commands/show_marks.c
@@ -24,7 +24,7 @@ struct cmd_results *cmd_show_marks(int argc, char **argv) {
24 config->show_marks = parse_boolean(argv[0], config->show_marks); 24 config->show_marks = parse_boolean(argv[0], config->show_marks);
25 25
26 if (config->show_marks) { 26 if (config->show_marks) {
27 container_for_each_descendant_dfs(&root_container, 27 container_for_each_descendant(&root_container,
28 rebuild_marks_iterator, NULL); 28 rebuild_marks_iterator, NULL);
29 } 29 }
30 30
diff --git a/sway/commands/unmark.c b/sway/commands/unmark.c
index 1ce2c56b..44ceccee 100644
--- a/sway/commands/unmark.c
+++ b/sway/commands/unmark.c
@@ -52,7 +52,7 @@ struct cmd_results *cmd_unmark(int argc, char **argv) {
52 view_find_and_unmark(mark); 52 view_find_and_unmark(mark);
53 } else { 53 } else {
54 // Remove all marks from all views 54 // Remove all marks from all views
55 container_for_each_descendant_dfs(&root_container, 55 container_for_each_descendant(&root_container,
56 remove_all_marks_iterator, NULL); 56 remove_all_marks_iterator, NULL);
57 } 57 }
58 free(mark); 58 free(mark);
diff --git a/sway/config.c b/sway/config.c
index c1ec77f9..bd14222a 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -822,7 +822,7 @@ void config_update_font_height(bool recalculate) {
822 size_t prev_max_height = config->font_height; 822 size_t prev_max_height = config->font_height;
823 config->font_height = 0; 823 config->font_height = 0;
824 824
825 container_for_each_descendant_dfs(&root_container, 825 container_for_each_descendant(&root_container,
826 find_font_height_iterator, &recalculate); 826 find_font_height_iterator, &recalculate);
827 827
828 // Also consider floating views 828 // Also consider floating views
@@ -830,7 +830,7 @@ void config_update_font_height(bool recalculate) {
830 struct sway_container *output = root_container.children->items[i]; 830 struct sway_container *output = root_container.children->items[i];
831 for (int j = 0; j < output->children->length; ++j) { 831 for (int j = 0; j < output->children->length; ++j) {
832 struct sway_container *ws = output->children->items[j]; 832 struct sway_container *ws = output->children->items[j];
833 container_for_each_descendant_dfs(ws->sway_workspace->floating, 833 container_for_each_descendant(ws->sway_workspace->floating,
834 find_font_height_iterator, &recalculate); 834 find_font_height_iterator, &recalculate);
835 } 835 }
836 } 836 }
diff --git a/sway/criteria.c b/sway/criteria.c
index 9077aa9b..a5df1eef 100644
--- a/sway/criteria.c
+++ b/sway/criteria.c
@@ -167,7 +167,7 @@ static bool criteria_matches_view(struct criteria *criteria,
167 return false; 167 return false;
168 } 168 }
169 list_t *urgent_views = create_list(); 169 list_t *urgent_views = create_list();
170 container_for_each_descendant_dfs(&root_container, 170 container_for_each_descendant(&root_container,
171 find_urgent_iterator, urgent_views); 171 find_urgent_iterator, urgent_views);
172 list_stable_sort(urgent_views, cmp_urgent); 172 list_stable_sort(urgent_views, cmp_urgent);
173 struct sway_view *target; 173 struct sway_view *target;
@@ -228,7 +228,7 @@ list_t *criteria_get_views(struct criteria *criteria) {
228 .criteria = criteria, 228 .criteria = criteria,
229 .matches = matches, 229 .matches = matches,
230 }; 230 };
231 container_for_each_descendant_dfs(&root_container, 231 container_for_each_descendant(&root_container,
232 criteria_get_views_iterator, &data); 232 criteria_get_views_iterator, &data);
233 233
234 // Scratchpad items which are hidden are not in the tree. 234 // Scratchpad items which are hidden are not in the tree.
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 6dd7cf7d..f7d15c50 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -375,8 +375,7 @@ struct sway_seat *seat_create(struct sway_input_manager *input,
375 // init the focus stack 375 // init the focus stack
376 wl_list_init(&seat->focus_stack); 376 wl_list_init(&seat->focus_stack);
377 377
378 container_for_each_descendant_dfs(&root_container, 378 container_for_each_descendant(&root_container, collect_focus_iter, seat);
379 collect_focus_iter, seat);
380 379
381 wl_signal_add(&root_container.sway_root->events.new_container, 380 wl_signal_add(&root_container.sway_root->events.new_container,
382 &seat->new_container); 381 &seat->new_container);
diff --git a/sway/ipc-server.c b/sway/ipc-server.c
index 7d2d8969..dad1f310 100644
--- a/sway/ipc-server.c
+++ b/sway/ipc-server.c
@@ -631,7 +631,7 @@ void ipc_client_handle_command(struct ipc_client *client) {
631 case IPC_GET_WORKSPACES: 631 case IPC_GET_WORKSPACES:
632 { 632 {
633 json_object *workspaces = json_object_new_array(); 633 json_object *workspaces = json_object_new_array();
634 container_for_each_descendant_dfs(&root_container, 634 container_for_each_descendant(&root_container,
635 ipc_get_workspaces_callback, workspaces); 635 ipc_get_workspaces_callback, workspaces);
636 const char *json_string = json_object_to_json_string(workspaces); 636 const char *json_string = json_object_to_json_string(workspaces);
637 client_valid = 637 client_valid =
diff --git a/sway/tree/container.c b/sway/tree/container.c
index aecb2ac6..06b3b005 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -25,21 +25,6 @@
25#include "log.h" 25#include "log.h"
26#include "stringop.h" 26#include "stringop.h"
27 27
28static list_t *bfs_queue;
29
30static list_t *get_bfs_queue() {
31 if (!bfs_queue) {
32 bfs_queue = create_list();
33 if (!bfs_queue) {
34 wlr_log(WLR_ERROR, "could not allocate list for bfs queue");
35 return NULL;
36 }
37 }
38 bfs_queue->length = 0;
39
40 return bfs_queue;
41}
42
43const char *container_type_to_str(enum sway_container_type type) { 28const char *container_type_to_str(enum sway_container_type type) {
44 switch (type) { 29 switch (type) {
45 case C_ROOT: 30 case C_ROOT:
@@ -450,7 +435,7 @@ struct sway_container *container_close(struct sway_container *con) {
450 if (con->type == C_VIEW) { 435 if (con->type == C_VIEW) {
451 view_close(con->sway_view); 436 view_close(con->sway_view);
452 } else { 437 } else {
453 container_for_each_descendant_dfs(con, container_close_func, NULL); 438 container_for_each_descendant(con, container_close_func, NULL);
454 } 439 }
455 440
456 return parent; 441 return parent;
@@ -760,7 +745,7 @@ struct sway_container *container_at(struct sway_container *workspace,
760 return NULL; 745 return NULL;
761} 746}
762 747
763void container_for_each_descendant_dfs(struct sway_container *container, 748void container_for_each_descendant(struct sway_container *container,
764 void (*f)(struct sway_container *container, void *data), 749 void (*f)(struct sway_container *container, void *data),
765 void *data) { 750 void *data) {
766 if (!container) { 751 if (!container) {
@@ -769,43 +754,19 @@ void container_for_each_descendant_dfs(struct sway_container *container,
769 if (container->children) { 754 if (container->children) {
770 for (int i = 0; i < container->children->length; ++i) { 755 for (int i = 0; i < container->children->length; ++i) {
771 struct sway_container *child = container->children->items[i]; 756 struct sway_container *child = container->children->items[i];
772 container_for_each_descendant_dfs(child, f, data); 757 container_for_each_descendant(child, f, data);
773 } 758 }
774 } 759 }
775 if (container->type == C_WORKSPACE) { 760 if (container->type == C_WORKSPACE) {
776 struct sway_container *floating = container->sway_workspace->floating; 761 struct sway_container *floating = container->sway_workspace->floating;
777 for (int i = 0; i < floating->children->length; ++i) { 762 for (int i = 0; i < floating->children->length; ++i) {
778 struct sway_container *child = floating->children->items[i]; 763 struct sway_container *child = floating->children->items[i];
779 container_for_each_descendant_dfs(child, f, data); 764 container_for_each_descendant(child, f, data);
780 } 765 }
781 } 766 }
782 f(container, data); 767 f(container, data);
783} 768}
784 769
785void container_for_each_descendant_bfs(struct sway_container *con,
786 void (*f)(struct sway_container *con, void *data), void *data) {
787 list_t *queue = get_bfs_queue();
788 if (!queue) {
789 return;
790 }
791
792 if (queue == NULL) {
793 wlr_log(WLR_ERROR, "could not allocate list");
794 return;
795 }
796
797 list_add(queue, con);
798
799 struct sway_container *current = NULL;
800 while (queue->length) {
801 current = queue->items[0];
802 list_del(queue, 0);
803 f(current, data);
804 // TODO floating containers
805 list_cat(queue, current->children);
806 }
807}
808
809bool container_has_ancestor(struct sway_container *descendant, 770bool container_has_ancestor(struct sway_container *descendant,
810 struct sway_container *ancestor) { 771 struct sway_container *ancestor) {
811 while (descendant->type != C_ROOT) { 772 while (descendant->type != C_ROOT) {
@@ -1289,8 +1250,7 @@ void container_set_fullscreen(struct sway_container *container, bool enable) {
1289 container_set_fullscreen(workspace->sway_workspace->fullscreen, false); 1250 container_set_fullscreen(workspace->sway_workspace->fullscreen, false);
1290 } 1251 }
1291 1252
1292 container_for_each_descendant_dfs(container, 1253 container_for_each_descendant(container, set_fullscreen_iterator, &enable);
1293 set_fullscreen_iterator, &enable);
1294 1254
1295 container->is_fullscreen = enable; 1255 container->is_fullscreen = enable;
1296 1256