diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2019-01-17 20:16:23 +1000 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2019-01-22 09:55:13 +0100 |
commit | 2301349ad59751640ed9e59dd22edeafaf09da39 (patch) | |
tree | 1726c2f8ec1cd9baaf27fbed62aa6a337bc85ce7 /sway/tree/output.c | |
parent | seat_create: set initial focus for added seats (diff) | |
download | sway-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/output.c')
-rw-r--r-- | sway/tree/output.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/sway/tree/output.c b/sway/tree/output.c index 50a2c535..5a992f2d 100644 --- a/sway/tree/output.c +++ b/sway/tree/output.c | |||
@@ -57,12 +57,12 @@ static void restore_workspaces(struct sway_output *output) { | |||
57 | } | 57 | } |
58 | 58 | ||
59 | // Saved workspaces | 59 | // Saved workspaces |
60 | for (int i = 0; i < root->saved_workspaces->length; ++i) { | 60 | while (root->noop_output->workspaces->length) { |
61 | struct sway_workspace *ws = root->saved_workspaces->items[i]; | 61 | struct sway_workspace *ws = root->noop_output->workspaces->items[0]; |
62 | workspace_detach(ws); | ||
62 | output_add_workspace(output, ws); | 63 | output_add_workspace(output, ws); |
63 | ipc_event_workspace(NULL, ws, "move"); | 64 | ipc_event_workspace(NULL, ws, "move"); |
64 | } | 65 | } |
65 | root->saved_workspaces->length = 0; | ||
66 | 66 | ||
67 | output_sort_workspaces(output); | 67 | output_sort_workspaces(output); |
68 | } | 68 | } |
@@ -177,6 +177,9 @@ static void output_evacuate(struct sway_output *output) { | |||
177 | if (!new_output) { | 177 | if (!new_output) { |
178 | new_output = fallback_output; | 178 | new_output = fallback_output; |
179 | } | 179 | } |
180 | if (!new_output) { | ||
181 | new_output = root->noop_output; | ||
182 | } | ||
180 | 183 | ||
181 | if (workspace_is_empty(workspace)) { | 184 | if (workspace_is_empty(workspace)) { |
182 | // If floating is not empty, there are sticky containers to move | 185 | // If floating is not empty, there are sticky containers to move |
@@ -187,14 +190,10 @@ static void output_evacuate(struct sway_output *output) { | |||
187 | continue; | 190 | continue; |
188 | } | 191 | } |
189 | 192 | ||
190 | if (new_output) { | 193 | workspace_output_add_priority(workspace, new_output); |
191 | workspace_output_add_priority(workspace, new_output); | 194 | output_add_workspace(new_output, workspace); |
192 | output_add_workspace(new_output, workspace); | 195 | output_sort_workspaces(new_output); |
193 | output_sort_workspaces(new_output); | 196 | ipc_event_workspace(NULL, workspace, "move"); |
194 | ipc_event_workspace(NULL, workspace, "move"); | ||
195 | } else { | ||
196 | list_add(root->saved_workspaces, workspace); | ||
197 | } | ||
198 | } | 197 | } |
199 | } | 198 | } |
200 | 199 | ||