Skip to content

Commit 875af50

Browse files
committed
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.
1 parent 9768f73 commit 875af50

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- On Wayland, bump `smithay-client-toolkit` to 0.15.1.
1717
- On Wayland, implement `request_user_attention` with `xdg_activation_v1`.
1818
- On X11, emit missing `WindowEvent::ScaleFactorChanged` when the only monitor gets reconnected.
19+
- On X11, if RANDR based scale factor is higher than 20 reset it to 1
1920

2021
# 0.25.0 (2021-05-15)
2122

src/platform_impl/linux/x11/util/randr.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ pub fn calc_dpi_factor(
2727
// Quantize 1/12 step size
2828
let dpi_factor = ((ppmm * (12.0 * 25.4 / 96.0)).round() / 12.0).max(1.0);
2929
assert!(validate_scale_factor(dpi_factor));
30-
dpi_factor
30+
if dpi_factor <= 20. {
31+
dpi_factor
32+
} else {
33+
1.
34+
}
3135
}
3236

3337
impl XConnection {

0 commit comments

Comments
 (0)