diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-08-11 15:57:09 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-08-11 15:57:09 +1000 |
commit | 4ad1ccc9dcd1e9090090dfbae153ded1b36af9ff (patch) | |
tree | 233e3977ad922df56a76d91e59606019fc21c38f /sway/tree/container.c | |
parent | Merge pull request #2447 from ianyfan/swaynag-leak (diff) | |
download | sway-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.
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r-- | sway/tree/container.c | 50 |
1 files changed, 5 insertions, 45 deletions
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 | ||
28 | static list_t *bfs_queue; | ||
29 | |||
30 | static 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 | |||
43 | const char *container_type_to_str(enum sway_container_type type) { | 28 | const 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 | ||
763 | void container_for_each_descendant_dfs(struct sway_container *container, | 748 | void 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 | ||
785 | void 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 | |||
809 | bool container_has_ancestor(struct sway_container *descendant, | 770 | bool 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 | ||