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 /alacritty/src/display/window.rs | |
parent | d872b9f3aed225bcae74ee3707a690c1a096608e (diff) | |
download | r-alacritty-fc87aaa4b10b9a5949fa2eae9e33ef66949b70d3.tar.gz r-alacritty-fc87aaa4b10b9a5949fa2eae9e33ef66949b70d3.tar.bz2 r-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.
Diffstat (limited to 'alacritty/src/display/window.rs')
-rw-r--r-- | alacritty/src/display/window.rs | 13 |
1 files changed, 12 insertions, 1 deletions
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, |