Destroy empty workspace when destroying its output

master
vilhalmer 7 years ago
parent 6595d07ec7
commit 621d2666b1
No known key found for this signature in database
GPG Key ID: 50CCC70C5AD25E4F

@ -204,16 +204,23 @@ static struct sway_container *container_workspace_destroy(
return NULL; return NULL;
} }
// Do not destroy this if it's the last workspace on this output
struct sway_container *output = container_parent(workspace, C_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; return NULL;
} }
wlr_log(L_DEBUG, "destroying workspace '%s'", workspace->name); wlr_log(L_DEBUG, "destroying workspace '%s'", workspace->name);
struct sway_container *parent = workspace->parent; if (!workspace_is_empty(workspace)) {
if (!workspace_is_empty(workspace) && output) {
// Move children to a different workspace on this output // Move children to a different workspace on this output
struct sway_container *new_workspace = NULL; struct sway_container *new_workspace = NULL;
for (int i = 0; i < output->children->length; i++) { 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( static struct sway_container *container_output_destroy(

Loading…
Cancel
Save