aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/output.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/tree/output.c')
-rw-r--r--sway/tree/output.c52
1 files changed, 42 insertions, 10 deletions
diff --git a/sway/tree/output.c b/sway/tree/output.c
index 8823eba0..ed7e941e 100644
--- a/sway/tree/output.c
+++ b/sway/tree/output.c
@@ -1,11 +1,39 @@
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
11static 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 }
17
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 }
29
30 arrange_output(other);
31 }
32
33 container_sort_workspaces(output);
34 arrange_output(output);
35}
36
9struct sway_container *output_create( 37struct sway_container *output_create(
10 struct sway_output *sway_output) { 38 struct sway_output *sway_output) {
11 const char *name = sway_output->wlr_output->name; 39 const char *name = sway_output->wlr_output->name;
@@ -56,19 +84,23 @@ struct sway_container *output_create(
56 output->width = size.width; 84 output->width = size.width;
57 output->height = size.height; 85 output->height = size.height;
58 86
59 // Create workspace 87 restore_workspaces(output);
60 char *ws_name = workspace_next_name(output->name); 88
61 wlr_log(L_DEBUG, "Creating default workspace %s", ws_name); 89 if (!output->children->length) {
62 struct sway_container *ws = workspace_create(output, ws_name); 90 // Create workspace
63 // Set each seat's focus if not already set 91 char *ws_name = workspace_next_name(output->name);
64 struct sway_seat *seat = NULL; 92 wlr_log(L_DEBUG, "Creating default workspace %s", ws_name);
65 wl_list_for_each(seat, &input_manager->seats, link) { 93 struct sway_container *ws = workspace_create(output, ws_name);
66 if (!seat->has_focus) { 94 // Set each seat's focus if not already set
67 seat_set_focus(seat, ws); 95 struct sway_seat *seat = NULL;
96 wl_list_for_each(seat, &input_manager->seats, link) {
97 if (!seat->has_focus) {
98 seat_set_focus(seat, ws);
99 }
68 } 100 }
101 free(ws_name);
69 } 102 }
70 103
71 free(ws_name);
72 container_create_notify(output); 104 container_create_notify(output);
73 return output; 105 return output;
74} 106}