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 | |
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
-rw-r--r-- | sway/tree/container.c | 3 | ||||
-rw-r--r-- | sway/tree/layout.c | 1 | ||||
-rw-r--r-- | sway/tree/output.c | 39 |
3 files changed, 22 insertions, 21 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index f36820b3..cd2c083c 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -445,9 +445,6 @@ void container_descendants(struct sway_container *root, | |||
445 | func(item, data); | 445 | func(item, data); |
446 | } | 446 | } |
447 | container_descendants(item, type, func, data); | 447 | container_descendants(item, type, func, data); |
448 | if (i < root->children->length && root->children->items[i] != item) { | ||
449 | --i; | ||
450 | } | ||
451 | } | 448 | } |
452 | } | 449 | } |
453 | 450 | ||
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index fc17d8c3..6d4cd088 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -184,6 +184,7 @@ void container_move_to(struct sway_container *container, | |||
184 | container_sort_workspaces(new_parent); | 184 | container_sort_workspaces(new_parent); |
185 | seat_set_focus(seat, new_parent); | 185 | seat_set_focus(seat, new_parent); |
186 | workspace_output_raise_priority(container, old_parent, new_parent); | 186 | workspace_output_raise_priority(container, old_parent, new_parent); |
187 | ipc_event_workspace(container, NULL, "move"); | ||
187 | } | 188 | } |
188 | container_notify_subtree_changed(old_parent); | 189 | container_notify_subtree_changed(old_parent); |
189 | container_notify_subtree_changed(new_parent); | 190 | container_notify_subtree_changed(new_parent); |
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 |