diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-06-04 19:44:33 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-06-04 19:46:19 +0300 |
| commit | c6c17cccac979575b6402729af39f7c998e90874 (patch) | |
| tree | 257860ff0450dbef776b3f30a8ea7e5697a7dd55 | |
| parent | b5ad0e12fd46f7ab06f4bbc0e80bf3f2d4395cbf (diff) | |
| download | niri-c6c17cccac979575b6402729af39f7c998e90874.tar.gz niri-c6c17cccac979575b6402729af39f7c998e90874.tar.bz2 niri-c6c17cccac979575b6402729af39f7c998e90874.zip | |
Add missing fullscreen check
Fixes crash when a window in a column requests to be unfullscreened.
| -rw-r--r-- | src/layout/mod.rs | 51 | ||||
| -rw-r--r-- | src/layout/workspace.rs | 8 |
2 files changed, 59 insertions, 0 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs index a444601b..ac8db5d3 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -2625,6 +2625,11 @@ mod tests { }, CloseWindow(#[proptest(strategy = "1..=5usize")] usize), FullscreenWindow(#[proptest(strategy = "1..=5usize")] usize), + SetFullscreenWindow { + #[proptest(strategy = "1..=5usize")] + window: usize, + is_fullscreen: bool, + }, FocusColumnLeft, FocusColumnRight, FocusColumnFirst, @@ -2913,6 +2918,12 @@ mod tests { Op::FullscreenWindow(id) => { layout.toggle_fullscreen(&id); } + Op::SetFullscreenWindow { + window, + is_fullscreen, + } => { + layout.set_fullscreen(&window, is_fullscreen); + } Op::FocusColumnLeft => layout.focus_left(), Op::FocusColumnRight => layout.focus_right(), Op::FocusColumnFirst => layout.focus_column_first(), @@ -3288,6 +3299,22 @@ mod tests { Op::FullscreenWindow(1), Op::FullscreenWindow(2), Op::FullscreenWindow(3), + Op::SetFullscreenWindow { + window: 1, + is_fullscreen: false, + }, + Op::SetFullscreenWindow { + window: 1, + is_fullscreen: true, + }, + Op::SetFullscreenWindow { + window: 2, + is_fullscreen: false, + }, + Op::SetFullscreenWindow { + window: 2, + is_fullscreen: true, + }, Op::FocusColumnLeft, Op::FocusColumnRight, Op::FocusWindowUp, @@ -3663,6 +3690,30 @@ mod tests { } #[test] + fn unfullscreen_window_in_column() { + let ops = [ + Op::AddOutput(1), + Op::AddWindow { + id: 1, + bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)), + min_max_size: (Size::from((0, 0)), Size::from((i32::MAX, i32::MAX))), + }, + Op::AddWindow { + id: 2, + bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)), + min_max_size: (Size::from((0, 0)), Size::from((i32::MAX, i32::MAX))), + }, + Op::ConsumeOrExpelWindowLeft, + Op::SetFullscreenWindow { + window: 2, + is_fullscreen: false, + }, + ]; + + check_ops(&ops); + } + + #[test] fn open_right_of_on_different_workspace() { let ops = [ Op::AddOutput(1), diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index 827228c6..1947475a 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -2129,6 +2129,10 @@ impl<W: LayoutElement> Workspace<W> { .find_map(|(col_idx, col)| col.position(window).map(|tile_idx| (col_idx, tile_idx))) .unwrap(); + if is_fullscreen == self.columns[col_idx].is_fullscreen { + return; + } + if is_fullscreen && col_idx == self.active_column_idx && self.columns[col_idx].tiles.len() == 1 @@ -3221,6 +3225,10 @@ impl<W: LayoutElement> Column<W> { } fn set_fullscreen(&mut self, is_fullscreen: bool) { + if self.is_fullscreen == is_fullscreen { + return; + } + assert_eq!(self.tiles.len(), 1); self.is_fullscreen = is_fullscreen; self.update_tile_sizes(false); |
