aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/tree/workspace.h3
-rw-r--r--sway/commands/move.c10
-rw-r--r--sway/tree/workspace.c15
3 files changed, 25 insertions, 3 deletions
diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h
index 41b59796..1adbe68a 100644
--- a/include/sway/tree/workspace.h
+++ b/include/sway/tree/workspace.h
@@ -105,6 +105,9 @@ struct sway_container *workspace_find_container(struct sway_workspace *ws,
105 */ 105 */
106struct sway_container *workspace_wrap_children(struct sway_workspace *ws); 106struct sway_container *workspace_wrap_children(struct sway_workspace *ws);
107 107
108void workspace_unwrap_children(struct sway_workspace *ws,
109 struct sway_container *wrap);
110
108void workspace_detach(struct sway_workspace *workspace); 111void workspace_detach(struct sway_workspace *workspace);
109 112
110void workspace_add_tiling(struct sway_workspace *workspace, 113void workspace_add_tiling(struct sway_workspace *workspace,
diff --git a/sway/commands/move.c b/sway/commands/move.c
index cdbad13e..5851520e 100644
--- a/sway/commands/move.c
+++ b/sway/commands/move.c
@@ -208,9 +208,13 @@ static void container_move_to_workspace(struct sway_container *container,
208 } 208 }
209 } else { 209 } else {
210 container_detach(container); 210 container_detach(container);
211 container->width = container->height = 0; 211 if (workspace_is_empty(workspace) && container->children) {
212 container->width_fraction = container->height_fraction = 0; 212 workspace_unwrap_children(workspace, container);
213 workspace_add_tiling(workspace, container); 213 } else {
214 container->width = container->height = 0;
215 container->width_fraction = container->height_fraction = 0;
216 workspace_add_tiling(workspace, container);
217 }
214 container_update_representation(container); 218 container_update_representation(container);
215 } 219 }
216 if (container->view) { 220 if (container->view) {
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index 0fa28951..3bcba8e5 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -641,6 +641,21 @@ struct sway_container *workspace_wrap_children(struct sway_workspace *ws) {
641 return middle; 641 return middle;
642} 642}
643 643
644void workspace_unwrap_children(struct sway_workspace *ws,
645 struct sway_container *wrap) {
646 if (!sway_assert(workspace_is_empty(ws),
647 "target workspace must be empty")) {
648 return;
649 }
650
651 ws->layout = wrap->layout;
652 while (wrap->children->length) {
653 struct sway_container *child = wrap->children->items[0];
654 container_detach(child);
655 workspace_add_tiling(ws, child);
656 }
657}
658
644void workspace_detach(struct sway_workspace *workspace) { 659void workspace_detach(struct sway_workspace *workspace) {
645 struct sway_output *output = workspace->output; 660 struct sway_output *output = workspace->output;
646 int index = list_find(output->workspaces, workspace); 661 int index = list_find(output->workspaces, workspace);