Skip to content

Commit

Permalink
Add a check for primary monitor workspace invariant
Browse files Browse the repository at this point in the history
  • Loading branch information
YaLTeR committed Nov 2, 2023
1 parent e7857ef commit 7ff91fe
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1066,13 +1066,27 @@ impl<W: LayoutElement> Layout<W> {
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"
);
}

Expand Down

0 comments on commit 7ff91fe

Please sign in to comment.