summaryrefslogtreecommitdiffstats
path: root/sway/tree/workspace.c
diff options
context:
space:
mode:
authorLibravatar Tony Crisci <tony@dubstepdish.com>2018-04-03 12:25:19 -0400
committerLibravatar Tony Crisci <tony@dubstepdish.com>2018-04-03 12:25:19 -0400
commitb4c5f79725142c78a398a22981392d645bc9d2e9 (patch)
treec6f836b1179c018c55b6dfead9cbca4e2fa97876 /sway/tree/workspace.c
parentrename _container_destroy to container_finish (diff)
downloadsway-b4c5f79725142c78a398a22981392d645bc9d2e9.tar.gz
sway-b4c5f79725142c78a398a22981392d645bc9d2e9.tar.zst
sway-b4c5f79725142c78a398a22981392d645bc9d2e9.zip
move view and workspace destructors to container.c
Diffstat (limited to 'sway/tree/workspace.c')
-rw-r--r--sway/tree/workspace.c39
1 files changed, 0 insertions, 39 deletions
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index 74330884..7d180009 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -208,45 +208,6 @@ struct sway_container *workspace_create(const char *name) {
208 return new_ws; 208 return new_ws;
209} 209}
210 210
211struct sway_container *container_workspace_destroy(
212 struct sway_container *workspace) {
213 if (!sway_assert(workspace, "cannot destroy null workspace")) {
214 return NULL;
215 }
216
217 // Do not destroy this if it's the last workspace on this output
218 struct sway_container *output = container_parent(workspace, C_OUTPUT);
219 if (output && output->children->length == 1) {
220 return NULL;
221 }
222
223 struct sway_container *parent = workspace->parent;
224 if (workspace->children->length == 0) {
225 // destroy the WS if there are no children (TODO check for floating)
226 wlr_log(L_DEBUG, "destroying workspace '%s'", workspace->name);
227 ipc_event_workspace(workspace, NULL, "empty");
228 } else {
229 // Move children to a different workspace on this output
230 struct sway_container *new_workspace = NULL;
231 // TODO move floating
232 for (int i = 0; i < output->children->length; i++) {
233 if (output->children->items[i] != workspace) {
234 new_workspace = output->children->items[i];
235 break;
236 }
237 }
238
239 wlr_log(L_DEBUG, "moving children to different workspace '%s' -> '%s'",
240 workspace->name, new_workspace->name);
241 for (int i = 0; i < workspace->children->length; i++) {
242 container_move_to(workspace->children->items[i], new_workspace);
243 }
244 }
245
246 container_destroy(workspace);
247 return parent;
248}
249
250/** 211/**
251 * Get the previous or next workspace on the specified output. Wraps around at 212 * Get the previous or next workspace on the specified output. Wraps around at
252 * the end and beginning. If next is false, the previous workspace is returned, 213 * the end and beginning. If next is false, the previous workspace is returned,