diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2025-03-22 13:52:08 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2025-03-22 13:57:37 +0300 |
| commit | ed20822ce947198e4106698d7afffd0a832a7b3c (patch) | |
| tree | 8efa601a22f9db500a6b3c8cc88a101c1f13b644 /src | |
| parent | e88dfae46fed95a2b302e1d1e805da10c2b95fa1 (diff) | |
| download | niri-ed20822ce947198e4106698d7afffd0a832a7b3c.tar.gz niri-ed20822ce947198e4106698d7afffd0a832a7b3c.tar.bz2 niri-ed20822ce947198e4106698d7afffd0a832a7b3c.zip | |
layout: Reset unfullscreen view offset when removing window
Another old bug found by randomized tests after I expanded the testing mock
window.
Diffstat (limited to 'src')
| -rw-r--r-- | src/layout/scrolling.rs | 7 | ||||
| -rw-r--r-- | src/layout/tests.rs | 46 |
2 files changed, 53 insertions, 0 deletions
diff --git a/src/layout/scrolling.rs b/src/layout/scrolling.rs index 1fd79256..9bb190a4 100644 --- a/src/layout/scrolling.rs +++ b/src/layout/scrolling.rs @@ -1063,6 +1063,13 @@ impl<W: LayoutElement> ScrollingSpace<W> { let tile = column.tiles.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 column.data.len() == 1 { if let WindowHeight::Auto { weight } = &mut column.data[0].height { diff --git a/src/layout/tests.rs b/src/layout/tests.rs index 8e1c3adf..f7e5c759 100644 --- a/src/layout/tests.rs +++ b/src/layout/tests.rs @@ -3262,6 +3262,52 @@ fn windowed_fullscreen_to_fullscreen() { 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 { if parent_id == id { return true; |
