Skip to content

Commit fc87aaa

Browse files
authored
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 alacritty#3214.
1 parent d872b9f commit fc87aaa

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
2121
- Segmentation fault on shutdown with Wayland
2222
- Incorrect estimated DPR with Wayland
2323
- Consecutive clipboard stores dropped on Wayland until the application is refocused
24+
- Alacritty failing to start on X11 with invalid DPI reported by XRandr
2425

2526
### Removed
2627

Diff for: alacritty/src/display/window.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ use crate::gl;
6060
#[cfg(all(feature = "x11", not(any(target_os = "macos", windows))))]
6161
static WINDOW_ICON: &[u8] = include_bytes!("../../alacritty.png");
6262

63+
/// Maximum DPR on X11 before it is assumed that XRandr is reporting incorrect values.
64+
#[cfg(all(feature = "x11", not(any(target_os = "macos", windows))))]
65+
const MAX_X11_DPR: f64 = 10.;
66+
6367
/// This should match the definition of IDI_ICON from `windows.rc`.
6468
#[cfg(windows)]
6569
const IDI_ICON: WORD = 0x101;
@@ -216,7 +220,14 @@ impl Window {
216220
None
217221
};
218222

219-
let dpr = windowed_context.window().scale_factor();
223+
#[allow(unused_mut)]
224+
let mut dpr = windowed_context.window().scale_factor();
225+
226+
// Handle winit reporting invalid values due to incorrect XRandr monitor metrics.
227+
#[cfg(all(feature = "x11", not(any(target_os = "macos", windows))))]
228+
if !is_wayland && dpr > MAX_X11_DPR {
229+
dpr = 1.;
230+
}
220231

221232
Ok(Self {
222233
current_mouse_cursor,

0 commit comments

Comments
 (0)