diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2018-06-07 19:36:16 -0400 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2018-06-08 13:08:00 -0400 |
commit | 5c9a917df9453f0463040b1164ba639b430f7833 (patch) | |
tree | 581a2b3056df2625de3d6dbcbb970b20fff260cb /sway/tree/output.c | |
parent | Merge pull request #2121 from martinetd/swaylock-ctrl-u (diff) | |
download | sway-5c9a917df9453f0463040b1164ba639b430f7833.tar.gz sway-5c9a917df9453f0463040b1164ba639b430f7833.tar.zst sway-5c9a917df9453f0463040b1164ba639b430f7833.zip |
Restore workspaces to outputs based on priority
Diffstat (limited to 'sway/tree/output.c')
-rw-r--r-- | sway/tree/output.c | 49 |
1 files changed, 39 insertions, 10 deletions
diff --git a/sway/tree/output.c b/sway/tree/output.c index 8823eba0..1ab8bed2 100644 --- a/sway/tree/output.c +++ b/sway/tree/output.c | |||
@@ -1,11 +1,35 @@ | |||
1 | #define _POSIX_C_SOURCE 200809L | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <string.h> | 2 | #include <string.h> |
3 | #include <strings.h> | 3 | #include <strings.h> |
4 | #include "sway/ipc-server.h" | ||
4 | #include "sway/output.h" | 5 | #include "sway/output.h" |
6 | #include "sway/tree/arrange.h" | ||
5 | #include "sway/tree/output.h" | 7 | #include "sway/tree/output.h" |
6 | #include "sway/tree/workspace.h" | 8 | #include "sway/tree/workspace.h" |
7 | #include "log.h" | 9 | #include "log.h" |
8 | 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 | } | ||
21 | |||
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"); | ||
26 | |||
27 | container_sort_workspaces(output); | ||
28 | arrange_output(output); | ||
29 | arrange_output(other); | ||
30 | } | ||
31 | } | ||
32 | |||
9 | struct sway_container *output_create( | 33 | struct sway_container *output_create( |
10 | struct sway_output *sway_output) { | 34 | struct sway_output *sway_output) { |
11 | const char *name = sway_output->wlr_output->name; | 35 | const char *name = sway_output->wlr_output->name; |
@@ -56,19 +80,24 @@ struct sway_container *output_create( | |||
56 | output->width = size.width; | 80 | output->width = size.width; |
57 | output->height = size.height; | 81 | output->height = size.height; |
58 | 82 | ||
59 | // Create workspace | 83 | container_descendants(&root_container, C_WORKSPACE, restore_workspace, |
60 | char *ws_name = workspace_next_name(output->name); | 84 | output); |
61 | wlr_log(L_DEBUG, "Creating default workspace %s", ws_name); | 85 | |
62 | struct sway_container *ws = workspace_create(output, ws_name); | 86 | if (!output->children->length) { |
63 | // Set each seat's focus if not already set | 87 | // Create workspace |
64 | struct sway_seat *seat = NULL; | 88 | char *ws_name = workspace_next_name(output->name); |
65 | wl_list_for_each(seat, &input_manager->seats, link) { | 89 | wlr_log(L_DEBUG, "Creating default workspace %s", ws_name); |
66 | if (!seat->has_focus) { | 90 | struct sway_container *ws = workspace_create(output, ws_name); |
67 | seat_set_focus(seat, ws); | 91 | // Set each seat's focus if not already set |
92 | struct sway_seat *seat = NULL; | ||
93 | wl_list_for_each(seat, &input_manager->seats, link) { | ||
94 | if (!seat->has_focus) { | ||
95 | seat_set_focus(seat, ws); | ||
96 | } | ||
68 | } | 97 | } |
98 | free(ws_name); | ||
69 | } | 99 | } |
70 | 100 | ||
71 | free(ws_name); | ||
72 | container_create_notify(output); | 101 | container_create_notify(output); |
73 | return output; | 102 | return output; |
74 | } | 103 | } |