Add missing fullscreen check

Fixes crash when a window in a column requests to be unfullscreened.
This commit is contained in:
Ivan Molodetskikh
2024-06-04 19:44:33 +03:00
parent b5ad0e12fd
commit c6c17cccac
2 changed files with 59 additions and 0 deletions
+51
View File
@@ -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,
@@ -3662,6 +3689,30 @@ mod tests {
check_ops(&ops);
}
#[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 = [
+8
View File
@@ -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);