aboutsummaryrefslogtreecommitdiff
path: root/sway/tree/workspace.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/tree/workspace.c')
-rw-r--r--sway/tree/workspace.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index e40792ae..62549434 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -714,14 +714,8 @@ void workspace_add_floating(struct sway_workspace *workspace,
node_set_dirty(&con->node);
}
-struct sway_container *workspace_insert_tiling(struct sway_workspace *workspace,
+void workspace_insert_tiling_direct(struct sway_workspace *workspace,
struct sway_container *con, int index) {
- if (con->workspace) {
- container_detach(con);
- }
- if (config->default_layout != L_NONE) {
- con = container_split(con, config->default_layout);
- }
list_insert(workspace->tiling, index, con);
con->workspace = workspace;
container_for_each_child(con, set_workspace, NULL);
@@ -729,6 +723,17 @@ struct sway_container *workspace_insert_tiling(struct sway_workspace *workspace,
workspace_update_representation(workspace);
node_set_dirty(&workspace->node);
node_set_dirty(&con->node);
+}
+
+struct sway_container *workspace_insert_tiling(struct sway_workspace *workspace,
+ struct sway_container *con, int index) {
+ if (con->workspace) {
+ container_detach(con);
+ }
+ if (config->default_layout != L_NONE) {
+ con = container_split(con, config->default_layout);
+ }
+ workspace_insert_tiling_direct(workspace, con, index);
return con;
}
@@ -846,3 +851,10 @@ size_t workspace_num_sticky_containers(struct sway_workspace *ws) {
workspace_for_each_container(ws, count_sticky_containers, &count);
return count;
}
+
+void workspace_squash(struct sway_workspace *workspace) {
+ for (int i = 0; i < workspace->tiling->length; i++) {
+ struct sway_container *child = workspace->tiling->items[i];
+ i += container_squash(child);
+ }
+}