@smbcloud / cli / commits / 16db790

Label two displays outer and inner even when none is flagged primary

With two integrated displays and no deviceName of "primary", both came out as inner. The lower screen ID is now treated as the outer display in that case. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-Authored-By: siGit Code v1.7.0 <noreply@sigit.si>

Seto Elkahfi committed Oct 26, 2026 at 09:46 UTC 16db79036dbb0d1f1f59c4608bd6e7c66039dcc9
1 file changed +23
crates/xcrs/src/xcrs.rs
+23
@@ -571,6 +571,11 @@ pub fn parse_integrated_displays(capabilities_json: &str) -> Result<Vec<SimDispl
571
572 integrated.sort_by_key(|(screen_id, ..)| *screen_id);
573 let count = integrated.len();
574 + // With two displays and none flagged `primary`, the lower screen ID is the
575 + // outer one, so neither display ends up mislabeled as inner.
576 + if count == 2 && !integrated.iter().any(|(_, _, primary, ..)| *primary) {
577 + integrated[0].2 = true;
578 + }
579 Ok(integrated
580 .into_iter()
581 .map(|(screen_id, name, primary, width, height)| SimDisplay {
@@ -3265,6 +3270,24 @@ SERIAL456 no permissions (user denied) usb:0-2 transport_id:3
3270 );
3271 }
3272
3273 + #[test]
3274 + fn two_displays_without_a_primary_flag_still_get_an_outer_and_an_inner() {
3275 + let json = r#"{"capabilities": {"displays": [
3276 + {"screenID": 3, "deviceName": "second", "displayName": "B",
3277 + "displayType": "integrated", "width": 200, "height": 300},
3278 + {"screenID": 1, "deviceName": "first", "displayName": "A",
3279 + "displayType": "integrated", "width": 100, "height": 150}]}}"#;
3280 + let displays = parse_integrated_displays(json).expect("displays should parse");
3281 +
3282 + assert_eq!(
3283 + displays
3284 + .iter()
3285 + .map(|d| (d.screen_id, d.role.as_str()))
3286 + .collect::<Vec<_>>(),
3287 + vec![(1, "outer"), (3, "inner")]
3288 + );
3289 + }
3290 +
3291 #[test]
3292 fn capabilities_without_any_display_are_an_error() {
3293 assert!(parse_integrated_displays(r#"{"capabilities": {}}"#).is_err());