layout: Fix crash due to workspace cleanup during switch

This commit is contained in:
Ivan Molodetskikh
2024-01-19 20:24:18 +04:00
parent 031133c052
commit 26c8cbb961
+17
View File
@@ -542,6 +542,7 @@ impl<W: LayoutElement> Layout<W> {
if !ws.has_windows()
&& idx != mon.active_workspace_idx
&& idx != mon.workspaces.len() - 1
&& mon.workspace_switch.is_none()
{
mon.workspaces.remove(idx);
@@ -2286,6 +2287,22 @@ mod tests {
check_ops_with_options(options, &ops);
}
#[test]
fn workspace_cleanup_during_switch() {
let ops = [
Op::AddOutput(1),
Op::AddWindow {
id: 1,
bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)),
min_max_size: (Size::from((0, 0)), Size::from((i32::MAX, i32::MAX))),
},
Op::FocusWorkspaceDown,
Op::CloseWindow(1),
];
check_ops(&ops);
}
fn arbitrary_spacing() -> impl Strategy<Value = u16> {
// Give equal weight to:
// - 0: the element is disabled