mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-22 02:01:55 +07:00
Add missing fullscreen check
Fixes crash when a window in a column requests to be unfullscreened.
This commit is contained in:
@@ -2625,6 +2625,11 @@ mod tests {
|
|||||||
},
|
},
|
||||||
CloseWindow(#[proptest(strategy = "1..=5usize")] usize),
|
CloseWindow(#[proptest(strategy = "1..=5usize")] usize),
|
||||||
FullscreenWindow(#[proptest(strategy = "1..=5usize")] usize),
|
FullscreenWindow(#[proptest(strategy = "1..=5usize")] usize),
|
||||||
|
SetFullscreenWindow {
|
||||||
|
#[proptest(strategy = "1..=5usize")]
|
||||||
|
window: usize,
|
||||||
|
is_fullscreen: bool,
|
||||||
|
},
|
||||||
FocusColumnLeft,
|
FocusColumnLeft,
|
||||||
FocusColumnRight,
|
FocusColumnRight,
|
||||||
FocusColumnFirst,
|
FocusColumnFirst,
|
||||||
@@ -2913,6 +2918,12 @@ mod tests {
|
|||||||
Op::FullscreenWindow(id) => {
|
Op::FullscreenWindow(id) => {
|
||||||
layout.toggle_fullscreen(&id);
|
layout.toggle_fullscreen(&id);
|
||||||
}
|
}
|
||||||
|
Op::SetFullscreenWindow {
|
||||||
|
window,
|
||||||
|
is_fullscreen,
|
||||||
|
} => {
|
||||||
|
layout.set_fullscreen(&window, is_fullscreen);
|
||||||
|
}
|
||||||
Op::FocusColumnLeft => layout.focus_left(),
|
Op::FocusColumnLeft => layout.focus_left(),
|
||||||
Op::FocusColumnRight => layout.focus_right(),
|
Op::FocusColumnRight => layout.focus_right(),
|
||||||
Op::FocusColumnFirst => layout.focus_column_first(),
|
Op::FocusColumnFirst => layout.focus_column_first(),
|
||||||
@@ -3288,6 +3299,22 @@ mod tests {
|
|||||||
Op::FullscreenWindow(1),
|
Op::FullscreenWindow(1),
|
||||||
Op::FullscreenWindow(2),
|
Op::FullscreenWindow(2),
|
||||||
Op::FullscreenWindow(3),
|
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::FocusColumnLeft,
|
||||||
Op::FocusColumnRight,
|
Op::FocusColumnRight,
|
||||||
Op::FocusWindowUp,
|
Op::FocusWindowUp,
|
||||||
@@ -3662,6 +3689,30 @@ mod tests {
|
|||||||
check_ops(&ops);
|
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]
|
#[test]
|
||||||
fn open_right_of_on_different_workspace() {
|
fn open_right_of_on_different_workspace() {
|
||||||
let ops = [
|
let ops = [
|
||||||
|
|||||||
@@ -2129,6 +2129,10 @@ impl<W: LayoutElement> Workspace<W> {
|
|||||||
.find_map(|(col_idx, col)| col.position(window).map(|tile_idx| (col_idx, tile_idx)))
|
.find_map(|(col_idx, col)| col.position(window).map(|tile_idx| (col_idx, tile_idx)))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
if is_fullscreen == self.columns[col_idx].is_fullscreen {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if is_fullscreen
|
if is_fullscreen
|
||||||
&& col_idx == self.active_column_idx
|
&& col_idx == self.active_column_idx
|
||||||
&& self.columns[col_idx].tiles.len() == 1
|
&& self.columns[col_idx].tiles.len() == 1
|
||||||
@@ -3221,6 +3225,10 @@ impl<W: LayoutElement> Column<W> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn set_fullscreen(&mut self, is_fullscreen: bool) {
|
fn set_fullscreen(&mut self, is_fullscreen: bool) {
|
||||||
|
if self.is_fullscreen == is_fullscreen {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
assert_eq!(self.tiles.len(), 1);
|
assert_eq!(self.tiles.len(), 1);
|
||||||
self.is_fullscreen = is_fullscreen;
|
self.is_fullscreen = is_fullscreen;
|
||||||
self.update_tile_sizes(false);
|
self.update_tile_sizes(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user