mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-24 02:01:18 +07:00
layout: Fix crash when a window opens next-to an only interactively moved window with no outputs
This commit is contained in:
+9
-1
@@ -1142,7 +1142,15 @@ impl<W: LayoutElement> Layout<W> {
|
|||||||
.filter(|move_| next_to == move_.tile.window().id())
|
.filter(|move_| next_to == move_.tile.window().id())
|
||||||
.is_some()
|
.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)
|
(0, WorkspaceAddWindowTarget::Auto)
|
||||||
} else {
|
} else {
|
||||||
let ws_idx = workspaces
|
let ws_idx = workspaces
|
||||||
|
|||||||
@@ -2937,6 +2937,39 @@ fn interactive_move_drop_on_other_output_during_animation() {
|
|||||||
check_ops(&ops);
|
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]
|
#[test]
|
||||||
fn set_width_fixed_negative() {
|
fn set_width_fixed_negative() {
|
||||||
let ops = [
|
let ops = [
|
||||||
|
|||||||
Reference in New Issue
Block a user