diff options
author | Christian Duerr <contact@christianduerr.com> | 2021-02-15 14:58:12 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-15 14:58:12 +0000 |
commit | fc87aaa4b10b9a5949fa2eae9e33ef66949b70d3 (patch) | |
tree | 6a346b8c80fe6b337f0eaba372237e2283bdf0e2 | |
parent | d872b9f3aed225bcae74ee3707a690c1a096608e (diff) | |
download | alacritty-fc87aaa4b10b9a5949fa2eae9e33ef66949b70d3.tar.gz alacritty-fc87aaa4b10b9a5949fa2eae9e33ef66949b70d3.zip |
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.
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | alacritty/src/display/window.rs | 13 |
2 files changed, 13 insertions, 1 deletions
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, |