aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authorRyan Dwyer <RyanDwyer@users.noreply.github.com>2018-07-18 10:39:08 +1000
committerGitHub <noreply@github.com>2018-07-18 10:39:08 +1000
commit5903fb46404f4f2b2ed56b83af8d68c40336bd5f (patch)
tree6badffb0c6ee33b4e23e914c4c9f9b39a625b5f3 /sway
parent48b911a4596f50b585a1073d32413236d9defb60 (diff)
parent8ce7e3b44eea0a270ecc35a9da2ae801aaf6bce1 (diff)
Merge pull request #2229 from vilhalmer/destroy-output-destroy-empty-workspaces
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 3f9d701a..02384199 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -199,16 +199,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(WLR_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++) {
@@ -230,7 +237,7 @@ static struct sway_container *container_workspace_destroy(
}
}
- return parent;
+ return output;
}
static struct sway_container *container_output_destroy(