diff options
author | Nathan Lilienthal <nathan@nixpulvis.com> | 2021-02-01 16:25:24 -0500 |
---|---|---|
committer | Christian Duerr <contact@christianduerr.com> | 2021-02-14 20:43:13 +0000 |
commit | 8b4c8e9d6b42620c9918e10e80dfc6f9fa2dfa6e (patch) | |
tree | 3aa070002f517ceec08bfe0a6da3e68b86616961 | |
parent | 5e8c9f1616b0f1f2ef44e38bbb4c4542c681b423 (diff) | |
download | alacritty-8b4c8e9d6b42620c9918e10e80dfc6f9fa2dfa6e.tar.gz alacritty-8b4c8e9d6b42620c9918e10e80dfc6f9fa2dfa6e.zip |
Fix the estimated DPR to 1 on Wayland.
On Wayland, regardless of the underlying scale factor for an output, The
scale factor is 1.0 until we receive the first DPRChanged event. To
correctly calculate the window sizes, we must use a DPR of 1.0 as well.
Ideally we would know what the DPR of the window we're being opened in
is going to be, and avoid the estimation guessing game, but that doesn't
seem possible with the current interfaces provided by the window
systems.
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | alacritty/src/display.rs | 20 |
2 files changed, 13 insertions, 8 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 72c77cd0..3bb29f37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Crash due to assertion failure on 32-bit architectures - Segmentation fault on shutdown with Wayland +- Incorrect estimated DPR with Wayland ## 0.7.1 diff --git a/alacritty/src/display.rs b/alacritty/src/display.rs index b5c2bfa9..cc62389a 100644 --- a/alacritty/src/display.rs +++ b/alacritty/src/display.rs @@ -169,9 +169,18 @@ pub struct Display { impl Display { pub fn new<E>(config: &Config, event_loop: &EventLoop<E>) -> Result<Display, Error> { - // Guess DPR based on first monitor. - let estimated_dpr = - event_loop.available_monitors().next().map(|m| m.scale_factor()).unwrap_or(1.); + #[cfg(any(not(feature = "x11"), target_os = "macos", windows))] + let is_x11 = false; + #[cfg(all(feature = "x11", not(any(target_os = "macos", windows))))] + let is_x11 = event_loop.is_x11(); + + // Guess DPR based on first monitor. On Wayland the initial frame always renders at a DPR + // of 1. + let estimated_dpr = if cfg!(any(target_os = "macos", windows)) || is_x11 { + event_loop.available_monitors().next().map(|m| m.scale_factor()).unwrap_or(1.) + } else { + 1. + }; // Guess the target window dimensions. let metrics = GlyphCache::static_metrics(config.ui_config.font.clone(), estimated_dpr)?; @@ -259,11 +268,6 @@ impl Display { #[cfg(target_os = "macos")] window.set_has_shadow(config.ui_config.background_opacity() >= 1.0); - #[cfg(all(feature = "x11", not(any(target_os = "macos", windows))))] - let is_x11 = event_loop.is_x11(); - #[cfg(not(any(feature = "x11", target_os = "macos", windows)))] - let is_x11 = false; - // On Wayland we can safely ignore this call, since the window isn't visible until you // actually draw something into it and commit those changes. #[cfg(not(any(target_os = "macos", windows)))] |