|
8 | 8 | #include "sway/tree/workspace.h" |
9 | 9 | #include "log.h" |
10 | 10 |
|
11 | | -static void restore_workspace(struct sway_container *ws, void *output) { |
12 | | - if (ws->parent == output) { |
13 | | - return; |
14 | | - } |
15 | | - |
16 | | - struct sway_container *highest = workspace_output_get_highest_available( |
17 | | - ws, NULL); |
18 | | - if (!highest) { |
19 | | - return; |
20 | | - } |
| 11 | +static void restore_workspaces(struct sway_container *output) { |
| 12 | + for (int i = 0; i < root_container.children->length; i++) { |
| 13 | + struct sway_container *other = root_container.children->items[i]; |
| 14 | + if (other == output) { |
| 15 | + continue; |
| 16 | + } |
21 | 17 |
|
22 | | - if (highest == output) { |
23 | | - struct sway_container *other = container_remove_child(ws); |
24 | | - container_add_child(output, ws); |
25 | | - ipc_event_workspace(ws, NULL, "move"); |
| 18 | + for (int j = 0; j < other->children->length; j++) { |
| 19 | + struct sway_container *ws = other->children->items[j]; |
| 20 | + struct sway_container *highest = |
| 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 | 30 | arrange_output(other); |
30 | 31 | } |
| 32 | + |
| 33 | + container_sort_workspaces(output); |
| 34 | + arrange_output(output); |
31 | 35 | } |
32 | 36 |
|
33 | 37 | struct sway_container *output_create( |
@@ -80,8 +84,7 @@ struct sway_container *output_create( |
80 | 84 | output->width = size.width; |
81 | 85 | output->height = size.height; |
82 | 86 |
|
83 | | - container_descendants(&root_container, C_WORKSPACE, restore_workspace, |
84 | | - output); |
| 87 | + restore_workspaces(output); |
85 | 88 |
|
86 | 89 | if (!output->children->length) { |
87 | 90 | // Create workspace |
|
0 commit comments