From 7ff91fe39423c9ffbef5da9644d5567b3a3c07c4 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Thu, 2 Nov 2023 09:39:37 +0400 Subject: Add a check for primary monitor workspace invariant --- src/layout.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/layout.rs') diff --git a/src/layout.rs b/src/layout.rs index 866e39ce..5426af95 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -1066,13 +1066,27 @@ impl Layout { let monitor_id = OutputId::new(&monitor.output); if idx == primary_idx { + for ws in &monitor.workspaces { + if ws.original_output == monitor_id { + // This is the primary monitor's own workspace. + continue; + } + + let own_monitor_exists = monitors + .iter() + .any(|m| OutputId::new(&m.output) == ws.original_output); + assert!( + !own_monitor_exists, + "primary monitor cannot have workspaces for which their own monitor exists" + ); + } } else { assert!( monitor .workspaces .iter() .any(|workspace| workspace.original_output == monitor_id), - "secondary monitor must have all own workspaces" + "secondary monitor must not have any non-own workspaces" ); } -- cgit