summaryrefslogtreecommitdiffstats
path: root/alacritty
diff options
context:
space:
mode:
authorNathan Lilienthal <nathan@nixpulvis.com>2021-02-01 16:25:24 -0500
committerNathan Lilienthal <nathan@nixpulvis.com>2021-02-04 09:30:10 -0500
commita5e2ccd5aba720cc63af4079e7f5e5afb6d9b893 (patch)
treef3bba71a1a5c5cc7e71f4360758f58f8349517b4 /alacritty
parent73759da0f52f7186181f7284a4c9cb9db0798d59 (diff)
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.
Diffstat (limited to 'alacritty')
-rw-r--r--alacritty/src/display/mod.rs20
1 files changed, 12 insertions, 8 deletions
diff --git a/alacritty/src/display/mod.rs b/alacritty/src/display/mod.rs
index 2a55402e..9c37bd0e 100644
--- a/alacritty/src/display/mod.rs
+++ b/alacritty/src/display/mod.rs
@@ -188,9 +188,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)?;
@@ -278,11 +287,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)))]