rust-windowing / winit

Window handling library in pure Rust
https://docs.rs/winit/
Apache License 2.0
4.85k stars 909 forks source link

`calc_dpi_factor` on X11 returns nonsensical scaling factor (featuring insane xrandr data) #1983

Closed retupmoca closed 3 years ago

retupmoca commented 3 years ago

On my machine, xrandr reports my physical display size as 1mm x 1mm. This confuses the calc_dpi_factor function quite badly, resulting in a scale factor of over 500. I set my Xft.dpi setting, which resolved the issue locally, but it might be worth making calc_dpi_factor slightly better at detecting insane xrandr data.

My first thought is to make the calc_dpi_factor function bail out if the final scaling factor is absurdly large (>100 or something?), similar to how it warns and gives up if the height/width is 0. It might be simpler to just check for the 1mm x 1mm case, though.

My xrandr data for the display in question: image

My actual usage via egui (with WINIT_X11_SCALE_FACTOR=randr): image

retupmoca commented 3 years ago

Note that this is a multi-monitor machine, so I don't know if the data winit is reading will actually be 1mm x 1mm.

Second display xrandr data: image