-
Notifications
You must be signed in to change notification settings - Fork 950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HiDPI: Physical size from xrandr may be unreliable (can be 0mm x 0mm) #543
Comments
Great job investigating this, but unfortunately you're one day too late: alacritty/alacritty#1341 It's interesting that
Though, we could use this as an additional fallback for anyone with only one active output. |
@francesca64 What about adding the ability to override the scale factor from some environment variable? I later realized that my GTK+ and QT programs work fine only because they read the scale factor from env variables that I have written to |
That sounds like a good idea. Which specific env vars? |
@francesca64 AFAIK every toolkit have their own.. such as GTK's |
I've opened a PR to "fix" this by returning 1.0 when either width or height are 0. Adding an environment variable should be simple so I can add that to the PR if a consensus about it has been found. (PR: #544) |
I think having a Users might not even know that an application uses |
I would suggest that |
With an |
Additionally, the DPI factor should be specified per-monitor, not per-window. Considering that along with the following:
While I'm not ultimately opposed to allowing consumers to override DPI factors, correctly doing that would require some engineering, and it would likely only be desirable to support it on X11 (X11 doesn't really have a native concept of logical pixels, so it's easy to do whatever we want; taking the same approach on macOS would be quite a mess). |
Then I would suggest just to allow overriding from And also, sometimes we HiDPI users do set different scale factors to different programs, due to their different design. So I think allowing overriding through a environment variable would be more viable in this case. |
Well, While this solution is imperfect (as it overrides for all monitors) it has the benefit of being easy to use and only requiring a few lines of code be added to winit, so I'm fine with it if it makes people happy. |
I'd be fine with |
Sounds good to me. I'm guessing you don't want to add the |
I can try. |
Well, I wouldn't want to burden you. It would only take me 5 minutes to do myself. Though, the only hard thing is knowing that you need to get the screen number from |
Which platforms should support the I don't think env variables are super useful on android/ios/emscripten but I can still add it for completeness sake. |
Don't worry about things currently returning 1.0, since I've already got a branch that fixes that (not on Android yet though; I'm still looking into that). However, for now I'd prefer we just stick to X11. macOS and Windows would require additional math and complexity with resizing (on X11, you only need to override the value stored in Though, I'm not sure about the situation with Wayland. You can ask @vberger about that (and more generally about the okay-ness of this design). |
I'd welcome any comments on this @vberger, I'm probably just going to introduce these changes for X11 first. So that should be good until any other platform wants to hook into the env variable. |
@francesca64 where would be the best place to document the env variable? I've added it to the changelog but it seems like this should probably be at least put into the documentation too. I can add it to |
Those are basically the only places we have where you could put it, though if I'm not lazy I'll make some sort of DPI guide soon (no promises though!). Just be sure to use the |
TIL that thing exists. I'll probably clean this up properly and add some documentation tomorrow. I might even get to adding the |
Hmm, while I understand the need of WINIT_HIDPI_FACTOR for x11 (which has an... approximate hidpi support), I'm not sure if it would make sense for this variable to have any effect on Wayland.
Hidpi support on Wayland works this way :
- the server tells the client about the scale factor of each monitor
- the server tells the client which monitor(s) the window is currently being drawn on
- the client draws its contents with whatever scale factor it wants and notifies the server of it (note that wayland scale factors are always integers)
- if the scale factor chosen by the client does not match that of the monitor, the compositor rescales accordingly.
As a result, a client can only look too small or too big if it does not actually draws with the scale factor it told the server it would...
My PR for hidpi support in wayland simply chooses as drawing scale factor the max of the scale factors of the monitors it is being displayed on, ensuring the server may need to downsample the contents, but never upsample.
In this context, I'm not sure what overriding the scale factor with an env variable would be useful for. So maybe this variable should be just ignored when using the wayland backend?
|
Sounds very reasonable to me. Would make sense then to just introduce it for X11, if anyone else is interested in the env variable it should be simple to add it at a later point too. |
I ran into this issue when trying to run
Alacritty
, which useswinit
, on my GPD Pocket with ArchLinux running GNOME 3.28.2 on Xorg. When starting the program,winit
will report the following error:Further investigation showed that
XConnection::get_output_info
returnedinf
for the HiDPI factor. Reading the source code I realized that the value is calculated from the resolution and the physical size of the screen, which are all fetched fromxrandr
. Trying to runxrandr
directly to see what's happening, and I ended up withNote that the physical size reported by
xrandr
is absurd, since it is shown as0mm x 0mm
. However, usingxdpyinfo
I got the normal physical size reported without problem:I believe this should be some issue with xrandr, however I have saw some other cases with similar problems without a fix:
https://bbs.archlinux.org/viewtopic.php?id=232288
http://xpra.org/trac/ticket/728
I also confirmed this problem with @farseerfc who also owns the same computer as mine.
Since all the other programs on my system work just fine (including the ones using GTK3, QT5, Java Swing, which all support HiDPI), I am wondering if it is possible for
winit
to fallback to some other mechanism to determine hidpi factor or simply set it to 1 if the physical screen size cannot be detected. Although this should be a problem of somewhere else, I think we can at least getwinit
to run on these strange devices...The text was updated successfully, but these errors were encountered: