summaryrefslogtreecommitdiff
path: root/sway/tree/container.c
diff options
context:
space:
mode:
authorRyan Dwyer <[email protected]>2018-06-09 08:43:57 +1000
committerGitHub <[email protected]>2018-06-09 08:43:57 +1000
commit0b798ed9543d55bd39782c3a4a4bc1789acd40d3 (patch)
tree1ef7bdd44c5b7684e2c5e7118d5b7ffdda1e4ba6 /sway/tree/container.c
parentc65c84444e58404f951c628221b7485da0684f19 (diff)
parente2b2fb0a0e3e7db3046aeef485621ff3f490cd61 (diff)
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(
sway_workspace->floating->parent = NULL;
_container_destroy(sway_workspace->floating);
+ list_foreach(sway_workspace->output_priority, free);
+ list_free(sway_workspace->output_priority);
+
free(sway_workspace);
if (output) {
@@ -234,24 +237,33 @@ static struct sway_container *container_output_destroy(
// program
if (root_container.children->length > 1) {
// Move workspace from this output to another output
- struct sway_container *other_output =
+ struct sway_container *fallback_output =
root_container.children->items[0];
- if (other_output == output) {
- other_output = root_container.children->items[1];
+ if (fallback_output == output) {
+ fallback_output = root_container.children->items[1];
}
while (output->children->length) {
struct sway_container *workspace = output->children->items[0];
+
+ struct sway_container *new_output =
+ workspace_output_get_highest_available(workspace, output);
+ if (!new_output) {
+ new_output = fallback_output;
+ workspace_output_add_priority(workspace, new_output);
+ }
+
container_remove_child(workspace);
- if (workspace->children->length > 0) {
- container_add_child(other_output, workspace);
+ if (!workspace_is_empty(workspace)) {
+ container_add_child(new_output, workspace);
ipc_event_workspace(workspace, NULL, "move");
} else {
container_workspace_destroy(workspace);
}
+
+ container_sort_workspaces(new_output);
+ arrange_output(new_output);
}
- container_sort_workspaces(other_output);
- arrange_output(other_output);
}
}