diff options
Diffstat (limited to 'src/layout.rs')
| -rw-r--r-- | src/layout.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/layout.rs b/src/layout.rs index cd8ea9b0..f72e57b4 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -363,6 +363,11 @@ impl<W: LayoutElement> MonitorSet<W> { if primary.workspaces[i].original_output == id { let ws = primary.workspaces.remove(i); workspaces.push(ws); + + if i <= primary.active_workspace_idx { + primary.active_workspace_idx = + primary.active_workspace_idx.saturating_sub(1); + } } } workspaces.reverse(); @@ -2573,4 +2578,33 @@ mod tests { } } } + + #[test] + fn primary_active_workspace_idx_not_updated_on_output_add() { + let ops = [ + Op::AddOutput(1), + Op::AddOutput(2), + Op::FocusOutput(1), + Op::AddWindow { + id: 0, + bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)), + activate: true, + }, + Op::FocusOutput(2), + Op::AddWindow { + id: 1, + bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)), + activate: true, + }, + Op::RemoveOutput(2), + Op::FocusWorkspace(3), + Op::AddOutput(2), + ]; + + let mut monitor_set = MonitorSet::default(); + for op in ops { + op.apply(&mut monitor_set); + monitor_set.verify_invariants(); + } + } } |
