summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar vilhalmer <vil@vil.lv>2018-07-08 17:35:01 -0400
committerLibravatar vilhalmer <vil@vil.lv>2018-07-08 21:55:24 -0400
commit621d2666b1ac214c63628bbe0ac8f5d6485cb501 (patch)
treeeffd4ee6864086668c7a90503bfd0d8f088776c3
parentMerge pull request #2226 from emersion/swaylock-daemonize-after-lock (diff)
downloadsway-621d2666b1ac214c63628bbe0ac8f5d6485cb501.tar.gz
sway-621d2666b1ac214c63628bbe0ac8f5d6485cb501.tar.zst
sway-621d2666b1ac214c63628bbe0ac8f5d6485cb501.zip
Destroy empty workspace when destroying its output
-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(
204 return NULL; 204 return NULL;
205 } 205 }
206 206
207 // Do not destroy this if it's the last workspace on this output
208 struct sway_container *output = container_parent(workspace, C_OUTPUT); 207 struct sway_container *output = container_parent(workspace, C_OUTPUT);
209 if (output && output->children->length == 1) { 208
209 // If we're destroying the output, it will be NULL here. Return the root so
210 // that it doesn't appear that the workspace has refused to be destoyed,
211 // which would leave it in a broken state with no parent.
212 if (output == NULL) {
213 return &root_container;
214 }
215
216 // Do not destroy this if it's the last workspace on this output
217 if (output->children->length == 1) {
210 return NULL; 218 return NULL;
211 } 219 }
212 220
213 wlr_log(L_DEBUG, "destroying workspace '%s'", workspace->name); 221 wlr_log(L_DEBUG, "destroying workspace '%s'", workspace->name);
214 222
215 struct sway_container *parent = workspace->parent; 223 if (!workspace_is_empty(workspace)) {
216 if (!workspace_is_empty(workspace) && output) {
217 // Move children to a different workspace on this output 224 // Move children to a different workspace on this output
218 struct sway_container *new_workspace = NULL; 225 struct sway_container *new_workspace = NULL;
219 for (int i = 0; i < output->children->length; i++) { 226 for (int i = 0; i < output->children->length; i++) {
@@ -235,7 +242,7 @@ static struct sway_container *container_workspace_destroy(
235 } 242 }
236 } 243 }
237 244
238 return parent; 245 return output;
239} 246}
240 247
241static struct sway_container *container_output_destroy( 248static struct sway_container *container_output_destroy(