forge
Explore
Log in

Don't you dare go Hollow

Fix by-idx workspace actions not cleaning up

Browse files at this commit

c29fdcaccb568c0f51dc50d71e4aa05b16a657cbIvan MolodetskikhParent: 8a08e01
src/layout.rsmodified+60 -0
@@ -1533,6 +1533,8 @@ impl<W: LayoutElement> Monitor<W> {
1533 1533
1534 // Don't animate this action.1534 // Don't animate this action.
1535 self.workspace_switch = None;1535 self.workspace_switch = None;
1536+
1537+ self.clean_up_workspaces();
1536 }1538 }
1537 1539
1538 pub fn switch_workspace_up(&mut self) {1540 pub fn switch_workspace_up(&mut self) {
@@ -1553,6 +1555,8 @@ impl<W: LayoutElement> Monitor<W> {
1553 ));1555 ));
1554 // Don't animate this action.1556 // Don't animate this action.
1555 self.workspace_switch = None;1557 self.workspace_switch = None;
1558+
1559+ self.clean_up_workspaces();
1556 }1560 }
1557 1561
1558 pub fn consume_into_column(&mut self) {1562 pub fn consume_into_column(&mut self) {
@@ -3226,6 +3230,62 @@ mod tests {
3226 assert_eq!(monitors[0].active_workspace_idx, 1);3230 assert_eq!(monitors[0].active_workspace_idx, 1);
3227 }3231 }
3228 3232
3233+ #[test]
3234+ fn move_to_workspace_by_idx_does_not_leave_empty_workspaces() {
3235+ let ops = [
3236+ Op::AddOutput(1),
3237+ Op::AddWindow {
3238+ id: 0,
3239+ bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)),
3240+ activate: true,
3241+ },
3242+ Op::MoveWindowToWorkspace(2),
3243+ ];
3244+
3245+ let mut layout = Layout::default();
3246+ for op in ops {
3247+ op.apply(&mut layout);
3248+ }
3249+
3250+ let MonitorSet::Normal { monitors, .. } = layout.monitor_set else {
3251+ unreachable!()
3252+ };
3253+
3254+ assert!(monitors[0].workspaces[0].has_windows());
3255+ }
3256+
3257+ #[test]
3258+ fn focus_workspace_by_idx_does_not_leave_empty_workspaces() {
3259+ let ops = [
3260+ Op::AddOutput(1),
3261+ Op::AddWindow {
3262+ id: 0,
3263+ bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)),
3264+ activate: true,
3265+ },
3266+ Op::FocusWorkspaceDown,
3267+ Op::AddWindow {
3268+ id: 1,
3269+ bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)),
3270+ activate: true,
3271+ },
3272+ Op::FocusWorkspaceUp,
3273+ Op::CloseWindow(0),
3274+ Op::FocusWorkspace(3),
3275+ ];
3276+
3277+ let mut layout = Layout::default();
3278+ for op in ops {
3279+ op.apply(&mut layout);
3280+ }
3281+
3282+ let MonitorSet::Normal { monitors, .. } = layout.monitor_set else {
3283+ unreachable!()
3284+ };
3285+
3286+ assert!(monitors[0].workspaces[0].has_windows());
3287+ }
3288+
3229 proptest! {3289 proptest! {
3230 #![proptest_config(ProptestConfig {3290 #![proptest_config(ProptestConfig {
3231 cases: if std::env::var_os("RUN_SLOW_TESTS").is_none() {3291 cases: if std::env::var_os("RUN_SLOW_TESTS").is_none() {