From 7b402678e46525f70c0d6756d4fc0d70bf6a9dc3 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Fri, 10 Dec 2021 09:20:41 -0700 Subject: [PATCH] gui: fix initial pixel geometry on hidpi displays refs: #1387 --- docs/changelog.md | 1 + wezterm-gui/src/termwindow/mod.rs | 17 +++++++++++++++++ window/src/os/x11/connection.rs | 1 + 3 files changed, 19 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index 945fc9c43..9ddac5aad 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -27,6 +27,7 @@ As features stabilize some brief notes about them will accumulate here. * Improved conformance of CUP, HVP, SLRM, STBM escape sequences by support empty first parameter. Thanks to [@ninjalj](https://github.com/ninjalj)! [#1377](https://github.com/wez/wezterm/pull/1377) * tab bar didn't correctly handle double-wide cells and could truncate at edges when using `format-tab-title` [#1371](https://github.com/wez/wezterm/issues/1371) * `wezterm cli --no-auto-start` was not respected +* Pixel geometry configured on the PTY in new windows could be incorrect on HiDPI displays until the window was resized [#1387](https://github.com/wez/wezterm/issues/1387) ### 20211205-192649-672c1cc1 diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs index 5a8883a77..2b7400020 100644 --- a/wezterm-gui/src/termwindow/mod.rs +++ b/wezterm-gui/src/termwindow/mod.rs @@ -550,6 +550,23 @@ impl TermWindow { pixel_height: (render_metrics.cell_size.height as usize * physical_rows) as u16, }; + if terminal_size != size { + // DPI is different from the default assumed DPI when the mux + // created the pty. We need to inform the kernel of the revised + // pixel geometry now + log::trace!( + "Initial geometry was {:?} but dpi-adjusted geometry \ + is {:?}; update the kernel pixel geometry for the ptys!", + terminal_size, + size + ); + if let Some(window) = mux.get_window(mux_window_id) { + for tab in window.iter() { + tab.resize(size); + } + }; + } + let h_context = DimensionContext { dpi: dpi as f32, pixel_max: terminal_size.pixel_width as f32, diff --git a/window/src/os/x11/connection.rs b/window/src/os/x11/connection.rs index 422a0ebc0..929a3f1d7 100644 --- a/window/src/os/x11/connection.rs +++ b/window/src/os/x11/connection.rs @@ -470,6 +470,7 @@ impl XConnection { log::trace!("xsettings are {:?}", xsettings); let default_dpi = RefCell::new(compute_default_dpi(&xrm, &xsettings)); + log::trace!("computed initial dpi: {:?}", default_dpi); xcb_imdkit::ImeClient::set_logger(|msg| log::debug!("Ime: {}", msg)); let ime = unsafe {