diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-11-30 09:18:33 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-12-01 22:24:21 -0800 |
| commit | 5ed5243be657bf31a5f83290aa6ba4cebce83ffd (patch) | |
| tree | cededdf79c50a4865a4d66a829267d1c66351f8d | |
| parent | 4560251e64a5e9947ba1d713a61d98ced7d0797e (diff) | |
| download | niri-5ed5243be657bf31a5f83290aa6ba4cebce83ffd.tar.gz niri-5ed5243be657bf31a5f83290aa6ba4cebce83ffd.tar.bz2 niri-5ed5243be657bf31a5f83290aa6ba4cebce83ffd.zip | |
layout: Fix possible crash when dropping move on different, animating output
| -rw-r--r-- | src/layout/mod.rs | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs index c2424ba8..bfe7282b 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -3313,15 +3313,15 @@ impl<W: LayoutElement> Layout<W> { (mon, ws_idx, position, offset) } else { let mon = &mut monitors[*active_monitor_idx]; - let ws_id = mon.active_workspace().id(); - let (_, offset) = mon - .workspaces_with_render_positions() - .find(|(ws, _)| ws.id() == ws_id) - .unwrap(); - let ws_idx = mon.active_workspace_idx(); - let ws = &mut mon.workspaces[ws_idx]; // No point in trying to use the pointer position on the wrong output. - let position = InsertPosition::NewColumn(ws.columns.len()); + let (ws, offset) = mon.workspaces_with_render_positions().next().unwrap(); + let position = ws.get_insert_position(Point::from((0., 0.))); + let ws_id = ws.id(); + let ws_idx = mon + .workspaces + .iter_mut() + .position(|ws| ws.id() == ws_id) + .unwrap(); (mon, ws_idx, position, offset) }; @@ -6334,6 +6334,37 @@ mod tests { layout.verify_invariants(); } + #[test] + fn interactive_move_drop_on_other_output_during_animation() { + let ops = [ + Op::AddOutput(3), + Op::AddWindow { + id: 3, + bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)), + min_max_size: Default::default(), + }, + Op::InteractiveMoveBegin { + window: 3, + output_idx: 3, + px: 0.0, + py: 0.0, + }, + Op::FocusWorkspaceDown, + Op::AddOutput(4), + Op::InteractiveMoveUpdate { + window: 3, + dx: 0.0, + dy: 8300.68619826683, + output_idx: 4, + px: 0.0, + py: 0.0, + }, + Op::RemoveOutput(4), + Op::InteractiveMoveEnd { window: 3 }, + ]; + check_ops(&ops); + } + fn arbitrary_spacing() -> impl Strategy<Value = f64> { // Give equal weight to: // - 0: the element is disabled |
