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:
Ivan Molodetskikh
2025-03-22 13:52:08 +03:00
parent e88dfae46f
commit ed20822ce9
2 changed files with 53 additions and 0 deletions
+7
View File
@@ -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 {
+46
View File
@@ -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;