diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2023-10-14 20:18:09 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2023-10-14 20:42:44 +0400 |
| commit | c29fdcaccb568c0f51dc50d71e4aa05b16a657cb (patch) | |
| tree | 0113d969c295697715b44ecde0df112bb2585718 /src/layout.rs | |
| parent | 8a08e01a2d4e0fcfd746b23d1538ac512a8c7e8c (diff) | |
| download | niri-c29fdcaccb568c0f51dc50d71e4aa05b16a657cb.tar.gz niri-c29fdcaccb568c0f51dc50d71e4aa05b16a657cb.tar.bz2 niri-c29fdcaccb568c0f51dc50d71e4aa05b16a657cb.zip | |
Fix by-idx workspace actions not cleaning up
Diffstat (limited to 'src/layout.rs')
| -rw-r--r-- | src/layout.rs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/layout.rs b/src/layout.rs index 49d4c917..6eb9d359 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -1533,6 +1533,8 @@ impl<W: LayoutElement> Monitor<W> { // Don't animate this action. self.workspace_switch = None; + + self.clean_up_workspaces(); } pub fn switch_workspace_up(&mut self) { @@ -1553,6 +1555,8 @@ impl<W: LayoutElement> Monitor<W> { )); // Don't animate this action. self.workspace_switch = None; + + self.clean_up_workspaces(); } pub fn consume_into_column(&mut self) { @@ -3226,6 +3230,62 @@ mod tests { assert_eq!(monitors[0].active_workspace_idx, 1); } + #[test] + fn move_to_workspace_by_idx_does_not_leave_empty_workspaces() { + let ops = [ + Op::AddOutput(1), + Op::AddWindow { + id: 0, + bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)), + activate: true, + }, + Op::MoveWindowToWorkspace(2), + ]; + + let mut layout = Layout::default(); + for op in ops { + op.apply(&mut layout); + } + + let MonitorSet::Normal { monitors, .. } = layout.monitor_set else { + unreachable!() + }; + + assert!(monitors[0].workspaces[0].has_windows()); + } + + #[test] + fn focus_workspace_by_idx_does_not_leave_empty_workspaces() { + let ops = [ + Op::AddOutput(1), + Op::AddWindow { + id: 0, + bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)), + activate: true, + }, + Op::FocusWorkspaceDown, + Op::AddWindow { + id: 1, + bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)), + activate: true, + }, + Op::FocusWorkspaceUp, + Op::CloseWindow(0), + Op::FocusWorkspace(3), + ]; + + let mut layout = Layout::default(); + for op in ops { + op.apply(&mut layout); + } + + let MonitorSet::Normal { monitors, .. } = layout.monitor_set else { + unreachable!() + }; + + assert!(monitors[0].workspaces[0].has_windows()); + } + proptest! { #