From 1bbd56d469271a30c547ee0da4d4743b67dc39b5 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sun, 6 Aug 2023 09:31:11 -0700 Subject: [PATCH] wayland: return effective_dpi in wezterm.gui.screens Note that this also does not respect dpi_by_screen; this is for consistency in behavior and reported values. Once we can produce the correct overridden value in dispatch_pending_event, we can update these functions to return the same data. refs: #4096 --- window/src/os/wayland/connection.rs | 7 ++++++- window/src/os/wayland/output.rs | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/window/src/os/wayland/connection.rs b/window/src/os/wayland/connection.rs index 27191dfb0..e94e6d0c3 100644 --- a/window/src/os/wayland/connection.rs +++ b/window/src/os/wayland/connection.rs @@ -479,6 +479,7 @@ impl ConnectionOps for WaylandConnection { let mut by_name = HashMap::new(); let mut virtual_rect: ScreenRect = euclid::rect(0, 0, 0, 0); + let config = config::configuration(); for output in self.environment.get_all_outputs() { toolkit::output::with_output_info(&output, |info| { let name = if info.name.is_empty() { @@ -503,6 +504,10 @@ impl ConnectionOps for WaylandConnection { let scale = info.scale_factor as f64; + // FIXME: teach this how to resolve dpi_by_screen once + // dispatch_pending_event knows how to do the same + let effective_dpi = Some(config.dpi.unwrap_or(scale * crate::DEFAULT_DPI)); + virtual_rect = virtual_rect.union(&rect); by_name.insert( name.clone(), @@ -511,7 +516,7 @@ impl ConnectionOps for WaylandConnection { rect, scale, max_fps: None, - effective_dpi: None, + effective_dpi, }, ); }); diff --git a/window/src/os/wayland/output.rs b/window/src/os/wayland/output.rs index fdc05f949..9970d9af4 100644 --- a/window/src/os/wayland/output.rs +++ b/window/src/os/wayland/output.rs @@ -206,6 +206,7 @@ impl OutputHandler { let mut by_name = HashMap::new(); let mut virtual_rect: ScreenRect = euclid::rect(0, 0, 0, 0); + let config = config::configuration(); log::debug!("zwlr_head_info: {:#?}", inner.zwlr_head_info); @@ -227,6 +228,9 @@ impl OutputHandler { height as isize, ); virtual_rect = virtual_rect.union(&rect); + // FIXME: teach this how to resolve dpi_by_screen once + // dispatch_pending_event knows how to do the same + let effective_dpi = Some(config.dpi.unwrap_or(scale * crate::DEFAULT_DPI)); by_name.insert( name.clone(), ScreenInfo { @@ -234,7 +238,7 @@ impl OutputHandler { rect, scale, max_fps: None, - effective_dpi: None, + effective_dpi, }, ); }