From dca0364f4c4893b2e062f643105869ec16f71f89 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Sat, 4 Jan 2025 18:02:38 +0300 Subject: [PATCH] Unname connector if a duplicate is detected --- src/backend/tty.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/backend/tty.rs b/src/backend/tty.rs index 60dc50bad..1a11839d7 100644 --- a/src/backend/tty.rs +++ b/src/backend/tty.rs @@ -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 });