mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-22 02:01:55 +07:00
layout: Reset unfullscreen view offset when removing window
Another old bug found by randomized tests after I expanded the testing mock window.
This commit is contained in:
@@ -1063,6 +1063,13 @@ impl<W: LayoutElement> ScrollingSpace<W> {
|
|||||||
let tile = column.tiles.remove(tile_idx);
|
let tile = column.tiles.remove(tile_idx);
|
||||||
column.data.remove(tile_idx);
|
column.data.remove(tile_idx);
|
||||||
|
|
||||||
|
// If we're removing a pending-unfullscreen window, we need to clear the stored view
|
||||||
|
// offset. There might be other pending-unfullscreen windows in this column but that's kind
|
||||||
|
// of an edge case, don't think we need to handle that.
|
||||||
|
if column_idx == self.active_column_idx && tile.is_fullscreen() && !column.is_fullscreen {
|
||||||
|
self.view_offset_before_fullscreen = None;
|
||||||
|
}
|
||||||
|
|
||||||
// If one window is left, reset its weight to 1.
|
// If one window is left, reset its weight to 1.
|
||||||
if column.data.len() == 1 {
|
if column.data.len() == 1 {
|
||||||
if let WindowHeight::Auto { weight } = &mut column.data[0].height {
|
if let WindowHeight::Auto { weight } = &mut column.data[0].height {
|
||||||
|
|||||||
@@ -3262,6 +3262,52 @@ fn windowed_fullscreen_to_fullscreen() {
|
|||||||
check_ops(&ops);
|
check_ops(&ops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn move_pending_unfullscreen_window_out_of_active_column() {
|
||||||
|
let ops = [
|
||||||
|
Op::AddOutput(1),
|
||||||
|
Op::AddWindow {
|
||||||
|
params: TestWindowParams::new(1),
|
||||||
|
},
|
||||||
|
Op::FullscreenWindow(1),
|
||||||
|
Op::Communicate(1),
|
||||||
|
Op::AddWindow {
|
||||||
|
params: TestWindowParams::new(2),
|
||||||
|
},
|
||||||
|
Op::ConsumeWindowIntoColumn,
|
||||||
|
// Window 1 is now pending unfullscreen.
|
||||||
|
// Moving it out should reset view_offset_before_fullscreen.
|
||||||
|
Op::MoveWindowToWorkspaceDown,
|
||||||
|
];
|
||||||
|
|
||||||
|
check_ops(&ops);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn move_unfocused_pending_unfullscreen_window_out_of_active_column() {
|
||||||
|
let ops = [
|
||||||
|
Op::AddOutput(1),
|
||||||
|
Op::AddWindow {
|
||||||
|
params: TestWindowParams::new(1),
|
||||||
|
},
|
||||||
|
Op::FullscreenWindow(1),
|
||||||
|
Op::Communicate(1),
|
||||||
|
Op::AddWindow {
|
||||||
|
params: TestWindowParams::new(2),
|
||||||
|
},
|
||||||
|
Op::ConsumeWindowIntoColumn,
|
||||||
|
// Window 1 is now pending unfullscreen.
|
||||||
|
// Moving it out should reset view_offset_before_fullscreen.
|
||||||
|
Op::FocusWindowDown,
|
||||||
|
Op::MoveWindowToWorkspace {
|
||||||
|
window_id: Some(1),
|
||||||
|
workspace_idx: 1,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
check_ops(&ops);
|
||||||
|
}
|
||||||
|
|
||||||
fn parent_id_causes_loop(layout: &Layout<TestWindow>, id: usize, mut parent_id: usize) -> bool {
|
fn parent_id_causes_loop(layout: &Layout<TestWindow>, id: usize, mut parent_id: usize) -> bool {
|
||||||
if parent_id == id {
|
if parent_id == id {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user