From f0157e03e72714264e684295fac226e2046f0b38 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Tue, 3 Sep 2024 12:13:04 +0300 Subject: Use libdisplay-info for make/model/serial parsing, implement throughout --- src/protocols/output_management.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/protocols') diff --git a/src/protocols/output_management.rs b/src/protocols/output_management.rs index 3839bdb4..4f1ac8c0 100644 --- a/src/protocols/output_management.rs +++ b/src/protocols/output_management.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use std::iter::zip; use std::mem; -use niri_config::{FloatOrInt, Vrr}; +use niri_config::{FloatOrInt, OutputName, Vrr}; use niri_ipc::Transform; use smithay::reexports::wayland_protocols_wlr::output_management::v1::server::{ zwlr_output_configuration_head_v1, zwlr_output_configuration_v1, zwlr_output_head_v1, @@ -403,12 +403,13 @@ where return; } Entry::Vacant(entry) => { + let name = OutputName::from_ipc_output(current_config); let mut config = g_state .current_config - .find(¤t_config.name) + .find(&name) .cloned() .unwrap_or_else(|| niri_config::Output { - name: current_config.name.clone(), + name: name.format_make_model_serial_or_connector(), ..Default::default() }); config.off = false; @@ -452,12 +453,13 @@ where ); } Entry::Vacant(entry) => { + let name = OutputName::from_ipc_output(current_config); let mut config = g_state .current_config - .find(¤t_config.name) + .find(&name) .cloned() .unwrap_or_else(|| niri_config::Output { - name: current_config.name.clone(), + name: name.format_make_model_serial_or_connector(), ..Default::default() }); config.off = true; @@ -841,6 +843,7 @@ fn send_new_head( .unwrap(); client_data.manager.head(&new_head); new_head.name(conf.name.clone()); + // Format matches what Output::new() does internally. new_head.description(format!("{} - {} - {}", conf.make, conf.model, conf.name)); if let Some((width, height)) = conf.physical_size { if let (Ok(a), Ok(b)) = (width.try_into(), height.try_into()) { @@ -877,6 +880,11 @@ fn send_new_head( if new_head.version() >= zwlr_output_head_v1::EVT_MODEL_SINCE { new_head.model(conf.model.clone()); } + if new_head.version() >= zwlr_output_head_v1::EVT_SERIAL_NUMBER_SINCE { + if let Some(serial) = &conf.serial { + new_head.serial_number(serial.clone()); + } + } if new_head.version() >= zwlr_output_head_v1::EVT_ADAPTIVE_SYNC_SINCE { new_head.adaptive_sync(match conf.vrr_enabled { -- cgit