summaryrefslogtreecommitdiffstats
path: root/sway/tree/container.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <RyanDwyer@users.noreply.github.com>2018-06-09 08:43:57 +1000
committerLibravatar GitHub <noreply@github.com>2018-06-09 08:43:57 +1000
commit0b798ed9543d55bd39782c3a4a4bc1789acd40d3 (patch)
tree1ef7bdd44c5b7684e2c5e7118d5b7ffdda1e4ba6 /sway/tree/container.c
parentMerge pull request #2121 from martinetd/swaylock-ctrl-u (diff)
parentSwitch restore workspaces to a nested for-loop (diff)
downloadsway-0b798ed9543d55bd39782c3a4a4bc1789acd40d3.tar.gz
sway-0b798ed9543d55bd39782c3a4a4bc1789acd40d3.tar.zst
sway-0b798ed9543d55bd39782c3a4a4bc1789acd40d3.zip
Merge pull request #2115 from RedSoxFan/restore-workspaces
Restore workspaces to output when re-enabled
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r--sway/tree/container.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index ca993c41..cd2c083c 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -213,6 +213,9 @@ static struct sway_container *container_workspace_destroy(
213 sway_workspace->floating->parent = NULL; 213 sway_workspace->floating->parent = NULL;
214 _container_destroy(sway_workspace->floating); 214 _container_destroy(sway_workspace->floating);
215 215
216 list_foreach(sway_workspace->output_priority, free);
217 list_free(sway_workspace->output_priority);
218
216 free(sway_workspace); 219 free(sway_workspace);
217 220
218 if (output) { 221 if (output) {
@@ -234,24 +237,33 @@ static struct sway_container *container_output_destroy(
234 // program 237 // program
235 if (root_container.children->length > 1) { 238 if (root_container.children->length > 1) {
236 // Move workspace from this output to another output 239 // Move workspace from this output to another output
237 struct sway_container *other_output = 240 struct sway_container *fallback_output =
238 root_container.children->items[0]; 241 root_container.children->items[0];
239 if (other_output == output) { 242 if (fallback_output == output) {
240 other_output = root_container.children->items[1]; 243 fallback_output = root_container.children->items[1];
241 } 244 }
242 245
243 while (output->children->length) { 246 while (output->children->length) {
244 struct sway_container *workspace = output->children->items[0]; 247 struct sway_container *workspace = output->children->items[0];
248
249 struct sway_container *new_output =
250 workspace_output_get_highest_available(workspace, output);
251 if (!new_output) {
252 new_output = fallback_output;
253 workspace_output_add_priority(workspace, new_output);
254 }
255
245 container_remove_child(workspace); 256 container_remove_child(workspace);
246 if (workspace->children->length > 0) { 257 if (!workspace_is_empty(workspace)) {
247 container_add_child(other_output, workspace); 258 container_add_child(new_output, workspace);
248 ipc_event_workspace(workspace, NULL, "move"); 259 ipc_event_workspace(workspace, NULL, "move");
249 } else { 260 } else {
250 container_workspace_destroy(workspace); 261 container_workspace_destroy(workspace);
251 } 262 }
263
264 container_sort_workspaces(new_output);
265 arrange_output(new_output);
252 } 266 }
253 container_sort_workspaces(other_output);
254 arrange_output(other_output);
255 } 267 }
256 } 268 }
257 269