aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authorvilhalmer <vil@vil.lv>2018-07-08 17:35:01 -0400
committervilhalmer <vil@vil.lv>2018-07-08 21:55:24 -0400
commit621d2666b1ac214c63628bbe0ac8f5d6485cb501 (patch)
treeeffd4ee6864086668c7a90503bfd0d8f088776c3 /sway
parent6595d07ec7fe4422590fc8f40e35af82518a1c43 (diff)
Destroy empty workspace when destroying its output
Diffstat (limited to 'sway')
-rw-r--r--sway/tree/container.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 5fdcb6e3..7cea43fa 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -204,16 +204,23 @@ static struct sway_container *container_workspace_destroy(
return NULL;
}
- // Do not destroy this if it's the last workspace on this output
struct sway_container *output = container_parent(workspace, C_OUTPUT);
- if (output && output->children->length == 1) {
+
+ // If we're destroying the output, it will be NULL here. Return the root so
+ // that it doesn't appear that the workspace has refused to be destoyed,
+ // which would leave it in a broken state with no parent.
+ if (output == NULL) {
+ return &root_container;
+ }
+
+ // Do not destroy this if it's the last workspace on this output
+ if (output->children->length == 1) {
return NULL;
}
wlr_log(L_DEBUG, "destroying workspace '%s'", workspace->name);
- struct sway_container *parent = workspace->parent;
- if (!workspace_is_empty(workspace) && output) {
+ if (!workspace_is_empty(workspace)) {
// Move children to a different workspace on this output
struct sway_container *new_workspace = NULL;
for (int i = 0; i < output->children->length; i++) {
@@ -235,7 +242,7 @@ static struct sway_container *container_workspace_destroy(
}
}
- return parent;
+ return output;
}
static struct sway_container *container_output_destroy(