Skip to content

Commit

Permalink
Unname connector if a duplicate is detected
Browse files Browse the repository at this point in the history
  • Loading branch information
YaLTeR committed Jan 4, 2025
1 parent 3777125 commit dca0364
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/backend/tty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,13 +649,34 @@ impl Tty {
crtc: Some(crtc),
} => {
let connector_name = format_connector_name(&connector);
let name = make_output_name(&device.drm, connector.handle(), connector_name);
let mut name =
make_output_name(&device.drm, connector.handle(), connector_name);
debug!(
"new connector: {} \"{}\"",
&name.connector,
name.format_make_model_serial(),
);

// Make/model/serial can match exactly between different physical monitors. This
// doesn't happen often, but our Layout does not support such duplicates and
// will panic.
//
// As a workaround, search for duplicates, and unname the current connector if
// one is found. Connector names are always unique.
let formatted = name.format_make_model_serial_or_connector();
for info in device.known_crtcs.values() {
if info.name.matches(&formatted) {
warn!("connector make/model/serial duplicates existing, unnaming");
name = OutputName {
connector: name.connector,
make: None,
model: None,
serial: None,
};
break;
}
}

// Assign an id to this crtc.
let id = OutputId::next();
device.known_crtcs.insert(crtc, CrtcInfo { id, name });
Expand Down

0 comments on commit dca0364

Please sign in to comment.