Add a check for primary monitor workspace invariant
Browse files at this commit7ff91fe39423c9ffbef5da9644d5567b3a3c07c4Parent: e7857ef1 changed file +15 -1
- src/layout.rs +15 -1
src/layout.rsmodified+15 -1
| @@ -1066,13 +1066,27 @@ impl<W: LayoutElement> Layout<W> { | |||
| 1066 | let monitor_id = OutputId::new(&monitor.output); | 1066 | let monitor_id = OutputId::new(&monitor.output); |
| 1067 | 1067 | ||
| 1068 | if idx == primary_idx { | 1068 | if idx == primary_idx { |
| 1069 | + for ws in &monitor.workspaces { | ||
| 1070 | + if ws.original_output == monitor_id { | ||
| 1071 | + // This is the primary monitor's own workspace. | ||
| 1072 | + continue; | ||
| 1073 | + } | ||
| 1074 | + | ||
| 1075 | + let own_monitor_exists = monitors | ||
| 1076 | + .iter() | ||
| 1077 | + .any(|m| OutputId::new(&m.output) == ws.original_output); | ||
| 1078 | + assert!( | ||
| 1079 | + !own_monitor_exists, | ||
| 1080 | + "primary monitor cannot have workspaces for which their own monitor exists" | ||
| 1081 | + ); | ||
| 1082 | + } | ||
| 1069 | } else { | 1083 | } else { |
| 1070 | assert!( | 1084 | assert!( |
| 1071 | monitor | 1085 | monitor |
| 1072 | .workspaces | 1086 | .workspaces |
| 1073 | .iter() | 1087 | .iter() |
| 1074 | .any(|workspace| workspace.original_output == monitor_id), | 1088 | .any(|workspace| workspace.original_output == monitor_id), |
| 1075 | - "secondary monitor must have all own workspaces" | 1089 | + "secondary monitor must not have any non-own workspaces" |
| 1076 | ); | 1090 | ); |
| 1077 | } | 1091 | } |
| 1078 | 1092 | ||