From b4774861db2f765ff016b1a3370ebf03debbd30d Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Sat, 30 Oct 2021 23:47:31 +0300 Subject: [PATCH] On X11, if RANDR based scale factor is higher than 20 reset it to 1 Some video drivers could set display metrics to odd values, which can result in extra large scale factors (e.g. winit is sending 720 for 5k screen on nvidia binary drivers), so let's just drop them to prevent clients from using them. The value 20 was picked, because the DPR for 8k @ 5 inch is ~18.36. Fixes #1983. --- CHANGELOG.md | 1 + src/platform_impl/linux/x11/util/randr.rs | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5541fa34..8fcbdae8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - On Wayland, bump `smithay-client-toolkit` to 0.15.1. - On Wayland, implement `request_user_attention` with `xdg_activation_v1`. - On X11, emit missing `WindowEvent::ScaleFactorChanged` when the only monitor gets reconnected. +- On X11, if RANDR based scale factor is higher than 20 reset it to 1 # 0.25.0 (2021-05-15) diff --git a/src/platform_impl/linux/x11/util/randr.rs b/src/platform_impl/linux/x11/util/randr.rs index b9258c68..0013b901 100644 --- a/src/platform_impl/linux/x11/util/randr.rs +++ b/src/platform_impl/linux/x11/util/randr.rs @@ -27,7 +27,11 @@ pub fn calc_dpi_factor( // Quantize 1/12 step size let dpi_factor = ((ppmm * (12.0 * 25.4 / 96.0)).round() / 12.0).max(1.0); assert!(validate_scale_factor(dpi_factor)); - dpi_factor + if dpi_factor <= 20. { + dpi_factor + } else { + 1. + } } impl XConnection {