aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFurkan Sahin <furkan-dev@proton.me>2026-02-01 21:53:06 -0500
committerFurkan Sahin <furkan-dev@proton.me>2026-02-01 21:53:06 -0500
commit0eaad01547654c09908ce452ffa61a0cd9cac8e5 (patch)
tree5873638be77dfa9fe35f1f70d876a1c808a7ebc6
parent629788a998b00c613dfe1d3756fa02d63d886574 (diff)
tree/workspace: fix crash on dragging container to workspace edgebandicoot
Problem: when dragging a parent container to the right of its children, sway crashes, the calculated insertion index could exceed the list bounds. The move logic would compute an index based on the pre-removal list state. Solution: Clamp the insertion index to [0, length].
-rw-r--r--sway/tree/workspace.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index 733a002b..b57fe5f2 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -842,6 +842,8 @@ struct sway_container *workspace_insert_tiling(struct sway_workspace *workspace,
if (config->default_layout != L_NONE) {
con = container_split(con, config->default_layout);
}
+ if (index < 0) index = 0;
+ else if (index > workspace->tiling->length) index = workspace->tiling->length;
workspace_insert_tiling_direct(workspace, con, index);
return con;
}