layout: Fix crash when a window opens next-to an only interactively moved window with no outputs

This commit is contained in:
Ivan Molodetskikh
2025-09-16 07:58:24 +03:00
parent cd0d45fdb8
commit b2d2a766e4
2 changed files with 42 additions and 1 deletions
+9 -1
View File
@@ -1142,7 +1142,15 @@ impl<W: LayoutElement> Layout<W> {
.filter(|move_| next_to == move_.tile.window().id())
.is_some()
{
// The next_to window is being interactively moved.
// The next_to window is being interactively moved. If there are no
// other windows, we may have no workspaces at all.
if workspaces.is_empty() {
workspaces.push(Workspace::new_no_outputs(
self.clock.clone(),
self.options.clone(),
));
}
(0, WorkspaceAddWindowTarget::Auto)
} else {
let ws_idx = workspaces
+33
View File
@@ -2937,6 +2937,39 @@ fn interactive_move_drop_on_other_output_during_animation() {
check_ops(&ops);
}
#[test]
fn add_window_next_to_only_interactively_moved_without_outputs() {
let ops = [
Op::AddWindow {
params: TestWindowParams::new(2),
},
Op::AddOutput(1),
Op::InteractiveMoveBegin {
window: 2,
output_idx: 1,
px: 0.0,
py: 0.0,
},
Op::InteractiveMoveUpdate {
window: 2,
dx: 0.0,
dy: 3586.692842955048,
output_idx: 1,
px: 0.0,
py: 0.0,
},
Op::RemoveOutput(1),
// We have no outputs, and the only existing window is interactively moved, meaning there
// are no workspaces either.
Op::AddWindowNextTo {
params: TestWindowParams::new(3),
next_to_id: 2,
},
];
check_ops(&ops);
}
#[test]
fn set_width_fixed_negative() {
let ops = [