forge
Explore
Log in

Don't you dare go Hollow

Unname connector if a duplicate is detected

Browse files at this commit

dca0364f4c4893b2e062f643105869ec16f71f89Ivan MolodetskikhParent: 3777125
src/backend/tty.rsmodified+22 -1
@@ -649,13 +649,34 @@ impl Tty {
649 crtc: Some(crtc),649 crtc: Some(crtc),
650 } => {650 } => {
651 let connector_name = format_connector_name(&connector);651 let connector_name = format_connector_name(&connector);
652- let name = make_output_name(&device.drm, connector.handle(), connector_name);652+ let mut name =
653+ make_output_name(&device.drm, connector.handle(), connector_name);
653 debug!(654 debug!(
654 "new connector: {} \"{}\"",655 "new connector: {} \"{}\"",
655 &name.connector,656 &name.connector,
656 name.format_make_model_serial(),657 name.format_make_model_serial(),
657 );658 );
658 659
660+ // Make/model/serial can match exactly between different physical monitors. This
661+ // doesn't happen often, but our Layout does not support such duplicates and
662+ // will panic.
663+ //
664+ // As a workaround, search for duplicates, and unname the current connector if
665+ // one is found. Connector names are always unique.
666+ let formatted = name.format_make_model_serial_or_connector();
667+ for info in device.known_crtcs.values() {
668+ if info.name.matches(&formatted) {
669+ warn!("connector make/model/serial duplicates existing, unnaming");
670+ name = OutputName {
671+ connector: name.connector,
672+ make: None,
673+ model: None,
674+ serial: None,
675+ };
676+ break;
677+ }
678+ }
679+
659 // Assign an id to this crtc.680 // Assign an id to this crtc.
660 let id = OutputId::next();681 let id = OutputId::next();
661 device.known_crtcs.insert(crtc, CrtcInfo { id, name });682 device.known_crtcs.insert(crtc, CrtcInfo { id, name });