diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2018-06-08 13:06:29 -0400 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2018-06-08 13:08:00 -0400 |
commit | e2b2fb0a0e3e7db3046aeef485621ff3f490cd61 (patch) | |
tree | 1ef7bdd44c5b7684e2c5e7118d5b7ffdda1e4ba6 /sway/tree/output.c | |
parent | Restore workspaces to outputs based on priority (diff) | |
download | sway-e2b2fb0a0e3e7db3046aeef485621ff3f490cd61.tar.gz sway-e2b2fb0a0e3e7db3046aeef485621ff3f490cd61.tar.zst sway-e2b2fb0a0e3e7db3046aeef485621ff3f490cd61.zip |
Switch restore workspaces to a nested for-loop
Diffstat (limited to 'sway/tree/output.c')
-rw-r--r-- | sway/tree/output.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/sway/tree/output.c b/sway/tree/output.c index 1ab8bed2..ed7e941e 100644 --- a/sway/tree/output.c +++ b/sway/tree/output.c | |||
@@ -8,26 +8,30 @@ | |||
8 | #include "sway/tree/workspace.h" | 8 | #include "sway/tree/workspace.h" |
9 | #include "log.h" | 9 | #include "log.h" |
10 | 10 | ||
11 | static void restore_workspace(struct sway_container *ws, void *output) { | 11 | static void restore_workspaces(struct sway_container *output) { |
12 | if (ws->parent == output) { | 12 | for (int i = 0; i < root_container.children->length; i++) { |
13 | return; | 13 | struct sway_container *other = root_container.children->items[i]; |
14 | } | 14 | if (other == output) { |
15 | 15 | continue; | |
16 | struct sway_container *highest = workspace_output_get_highest_available( | 16 | } |
17 | ws, NULL); | ||
18 | if (!highest) { | ||
19 | return; | ||
20 | } | ||
21 | 17 | ||
22 | if (highest == output) { | 18 | for (int j = 0; j < other->children->length; j++) { |
23 | struct sway_container *other = container_remove_child(ws); | 19 | struct sway_container *ws = other->children->items[j]; |
24 | container_add_child(output, ws); | 20 | struct sway_container *highest = |
25 | ipc_event_workspace(ws, NULL, "move"); | 21 | workspace_output_get_highest_available(ws, NULL); |
22 | if (highest == output) { | ||
23 | container_remove_child(ws); | ||
24 | container_add_child(output, ws); | ||
25 | ipc_event_workspace(ws, NULL, "move"); | ||
26 | j--; | ||
27 | } | ||
28 | } | ||
26 | 29 | ||
27 | container_sort_workspaces(output); | ||
28 | arrange_output(output); | ||
29 | arrange_output(other); | 30 | arrange_output(other); |
30 | } | 31 | } |
32 | |||
33 | container_sort_workspaces(output); | ||
34 | arrange_output(output); | ||
31 | } | 35 | } |
32 | 36 | ||
33 | struct sway_container *output_create( | 37 | struct sway_container *output_create( |
@@ -80,8 +84,7 @@ struct sway_container *output_create( | |||
80 | output->width = size.width; | 84 | output->width = size.width; |
81 | output->height = size.height; | 85 | output->height = size.height; |
82 | 86 | ||
83 | container_descendants(&root_container, C_WORKSPACE, restore_workspace, | 87 | restore_workspaces(output); |
84 | output); | ||
85 | 88 | ||
86 | if (!output->children->length) { | 89 | if (!output->children->length) { |
87 | // Create workspace | 90 | // Create workspace |