aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/root.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2019-01-17 20:16:23 +1000
committerLibravatar emersion <contact@emersion.fr>2019-01-22 09:55:13 +0100
commit2301349ad59751640ed9e59dd22edeafaf09da39 (patch)
tree1726c2f8ec1cd9baaf27fbed62aa6a337bc85ce7 /sway/tree/root.c
parentseat_create: set initial focus for added seats (diff)
downloadsway-2301349ad59751640ed9e59dd22edeafaf09da39.tar.gz
sway-2301349ad59751640ed9e59dd22edeafaf09da39.tar.zst
sway-2301349ad59751640ed9e59dd22edeafaf09da39.zip
Use noop output when there's no outputs connected
Instead of having NULL workspace->output pointers, use a noop output. This should be safer.
Diffstat (limited to 'sway/tree/root.c')
-rw-r--r--sway/tree/root.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/sway/tree/root.c b/sway/tree/root.c
index d4b97be3..ec6bccf6 100644
--- a/sway/tree/root.c
+++ b/sway/tree/root.c
@@ -39,7 +39,6 @@ struct sway_root *root_create(void) {
39 wl_signal_init(&root->events.new_node); 39 wl_signal_init(&root->events.new_node);
40 root->outputs = create_list(); 40 root->outputs = create_list();
41 root->scratchpad = create_list(); 41 root->scratchpad = create_list();
42 root->saved_workspaces = create_list();
43 42
44 root->output_layout_change.notify = output_layout_handle_change; 43 root->output_layout_change.notify = output_layout_handle_change;
45 wl_signal_add(&root->output_layout->events.change, 44 wl_signal_add(&root->output_layout->events.change,
@@ -50,7 +49,6 @@ struct sway_root *root_create(void) {
50void root_destroy(struct sway_root *root) { 49void root_destroy(struct sway_root *root) {
51 wl_list_remove(&root->output_layout_change.link); 50 wl_list_remove(&root->output_layout_change.link);
52 list_free(root->scratchpad); 51 list_free(root->scratchpad);
53 list_free(root->saved_workspaces);
54 list_free(root->outputs); 52 list_free(root->outputs);
55 wlr_output_layout_destroy(root->output_layout); 53 wlr_output_layout_destroy(root->output_layout);
56 free(root); 54 free(root);
@@ -327,8 +325,8 @@ void root_for_each_container(void (*f)(struct sway_container *con, void *data),
327 } 325 }
328 326
329 // Saved workspaces 327 // Saved workspaces
330 for (int i = 0; i < root->saved_workspaces->length; ++i) { 328 for (int i = 0; i < root->noop_output->workspaces->length; ++i) {
331 struct sway_workspace *ws = root->saved_workspaces->items[i]; 329 struct sway_workspace *ws = root->noop_output->workspaces->items[i];
332 workspace_for_each_container(ws, f, data); 330 workspace_for_each_container(ws, f, data);
333 } 331 }
334} 332}
@@ -380,8 +378,8 @@ struct sway_container *root_find_container(
380 } 378 }
381 379
382 // Saved workspaces 380 // Saved workspaces
383 for (int i = 0; i < root->saved_workspaces->length; ++i) { 381 for (int i = 0; i < root->noop_output->workspaces->length; ++i) {
384 struct sway_workspace *ws = root->saved_workspaces->items[i]; 382 struct sway_workspace *ws = root->noop_output->workspaces->items[i];
385 if ((result = workspace_find_container(ws, test, data))) { 383 if ((result = workspace_find_container(ws, test, data))) {
386 return result; 384 return result;
387 } 385 }