cmd_move: respect workspace layout when inserting

When moving a container to become a direct child of the workspace and
the workspace's layout is tabbed or stacked, wrap it in a container
with the same layout. This allows for the following:
- Run `layout tabbed|stacked` on an empty workspace (or use
  `workspace_layout tabbed|stacked` in the config)
- Open some views
- Move one of the views in any direction
- Open another view
- The new container should also be `tabbed`/`stacked`
This commit is contained in:
Brian Ashworth 2019-04-24 20:28:19 -04:00 committed by Drew DeVault
parent dc7a3930a7
commit 462ad4ea83
2 changed files with 7 additions and 2 deletions

View file

@ -1385,8 +1385,10 @@ void container_replace(struct sway_container *container,
root_scratchpad_show(container); root_scratchpad_show(container);
root_scratchpad_remove_container(container); root_scratchpad_remove_container(container);
} }
container_add_sibling(container, replacement, 1); if (container->parent || container->workspace) {
container_detach(container); container_add_sibling(container, replacement, 1);
container_detach(container);
}
if (scratchpad) { if (scratchpad) {
root_scratchpad_add_container(replacement); root_scratchpad_add_container(replacement);
} }

View file

@ -688,6 +688,9 @@ void workspace_insert_tiling(struct sway_workspace *workspace,
if (con->workspace) { if (con->workspace) {
container_detach(con); container_detach(con);
} }
if (workspace->layout == L_STACKED || workspace->layout == L_TABBED) {
con = container_split(con, workspace->layout);
}
list_insert(workspace->tiling, index, con); list_insert(workspace->tiling, index, con);
con->workspace = workspace; con->workspace = workspace;
container_for_each_child(con, set_workspace, NULL); container_for_each_child(con, set_workspace, NULL);