From fc87aaa4b10b9a5949fa2eae9e33ef66949b70d3 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Mon, 15 Feb 2021 14:58:12 +0000 Subject: Limit the maximum DPR on X11 to 10 Since there have a bunch of problems caused by an excessive DPI reported by XRandr, this limits the maximum DPR on X11 to 10. These issues would commonly cause problems like long startup times or crashes, which are hard to troubleshoot for the user. While a limit of 10 might not eliminate all of these issues, it should still make it possible for Alacritty to start to make troubleshooting simpler. Fixes #3214. --- CHANGELOG.md | 1 + alacritty/src/display/window.rs | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78a2ef01..e568c92d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Segmentation fault on shutdown with Wayland - Incorrect estimated DPR with Wayland - Consecutive clipboard stores dropped on Wayland until the application is refocused +- Alacritty failing to start on X11 with invalid DPI reported by XRandr ### Removed diff --git a/alacritty/src/display/window.rs b/alacritty/src/display/window.rs index 1bd3525a..7302c687 100644 --- a/alacritty/src/display/window.rs +++ b/alacritty/src/display/window.rs @@ -60,6 +60,10 @@ use crate::gl; #[cfg(all(feature = "x11", not(any(target_os = "macos", windows))))] static WINDOW_ICON: &[u8] = include_bytes!("../../alacritty.png"); +/// Maximum DPR on X11 before it is assumed that XRandr is reporting incorrect values. +#[cfg(all(feature = "x11", not(any(target_os = "macos", windows))))] +const MAX_X11_DPR: f64 = 10.; + /// This should match the definition of IDI_ICON from `windows.rc`. #[cfg(windows)] const IDI_ICON: WORD = 0x101; @@ -216,7 +220,14 @@ impl Window { None }; - let dpr = windowed_context.window().scale_factor(); + #[allow(unused_mut)] + let mut dpr = windowed_context.window().scale_factor(); + + // Handle winit reporting invalid values due to incorrect XRandr monitor metrics. + #[cfg(all(feature = "x11", not(any(target_os = "macos", windows))))] + if !is_wayland && dpr > MAX_X11_DPR { + dpr = 1.; + } Ok(Self { current_mouse_cursor, -- cgit