Skip to content

Commit

Permalink
On X11, if RANDR based scale factor is higher than 20 reset it to 1
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kchibisov committed Oct 30, 2021
1 parent 9768f73 commit b477486
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 5 additions & 1 deletion src/platform_impl/linux/x11/util/randr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b477486

Please sign in to comment.