diff options
author | Ryan Dwyer <RyanDwyer@users.noreply.github.com> | 2018-07-18 10:39:08 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-18 10:39:08 +1000 |
commit | 5903fb46404f4f2b2ed56b83af8d68c40336bd5f (patch) | |
tree | 6badffb0c6ee33b4e23e914c4c9f9b39a625b5f3 | |
parent | Merge pull request #2281 from pvsr/X11_click (diff) | |
parent | Merge branch 'master' into destroy-output-destroy-empty-workspaces (diff) | |
download | sway-5903fb46404f4f2b2ed56b83af8d68c40336bd5f.tar.gz sway-5903fb46404f4f2b2ed56b83af8d68c40336bd5f.tar.zst sway-5903fb46404f4f2b2ed56b83af8d68c40336bd5f.zip |
Merge pull request #2229 from vilhalmer/destroy-output-destroy-empty-workspaces
Destroy empty workspace when destroying its output
-rw-r--r-- | sway/tree/container.c | 17 |
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( | |||
199 | return NULL; | 199 | return NULL; |
200 | } | 200 | } |
201 | 201 | ||
202 | // Do not destroy this if it's the last workspace on this output | ||
203 | struct sway_container *output = container_parent(workspace, C_OUTPUT); | 202 | struct sway_container *output = container_parent(workspace, C_OUTPUT); |
204 | if (output && output->children->length == 1) { | 203 | |
204 | // If we're destroying the output, it will be NULL here. Return the root so | ||
205 | // that it doesn't appear that the workspace has refused to be destoyed, | ||
206 | // which would leave it in a broken state with no parent. | ||
207 | if (output == NULL) { | ||
208 | return &root_container; | ||
209 | } | ||
210 | |||
211 | // Do not destroy this if it's the last workspace on this output | ||
212 | if (output->children->length == 1) { | ||
205 | return NULL; | 213 | return NULL; |
206 | } | 214 | } |
207 | 215 | ||
208 | wlr_log(WLR_DEBUG, "destroying workspace '%s'", workspace->name); | 216 | wlr_log(WLR_DEBUG, "destroying workspace '%s'", workspace->name); |
209 | 217 | ||
210 | struct sway_container *parent = workspace->parent; | 218 | if (!workspace_is_empty(workspace)) { |
211 | if (!workspace_is_empty(workspace) && output) { | ||
212 | // Move children to a different workspace on this output | 219 | // Move children to a different workspace on this output |
213 | struct sway_container *new_workspace = NULL; | 220 | struct sway_container *new_workspace = NULL; |
214 | for (int i = 0; i < output->children->length; i++) { | 221 | for (int i = 0; i < output->children->length; i++) { |
@@ -230,7 +237,7 @@ static struct sway_container *container_workspace_destroy( | |||
230 | } | 237 | } |
231 | } | 238 | } |
232 | 239 | ||
233 | return parent; | 240 | return output; |
234 | } | 241 | } |
235 | 242 | ||
236 | static struct sway_container *container_output_destroy( | 243 | static struct sway_container *container_output_destroy( |