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-20 16:10:36 -0500
commit3e7d3b8eec40e8b39360845b50e02a52829a2abe (patch)
tree3302ed1fcc210fda654ce0d1c5ca0a4cf18a4055
parentfa497964fd55632beacf5f425e964ae4893e25b9 (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.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index 733a002b..ddae8de4 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -842,6 +842,11 @@ 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;
}