-
Notifications
You must be signed in to change notification settings - Fork 603
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
Support for high DPI screens #202
Comments
Are you using |
I checked now and found that |
That's unfortunate :/ Out of curiosity, if you manually resize your screen class to scale everything by 2 does it appear as you desire? (by 2 to go from 1920x1080 to 3840x2160). If it does, then I'm not sure what to say. At the top of
There doesn't appear to be anything in there that wouldn't work on linux, and I know this code is reliable for OSX. |
Thank you for your help! The version I'm using does include a path for Linux in
I'm on Mate and Wonder if there's a way to get that value that works on more Linux desktops. |
A quick test shows that forcing the return value of |
Ahhh I see the problem. Mate != Gnome, so even if you set Before investigating more obtuse alternatives, does it work if you get rid of the
? If that code is also not working for you, there are alternatives. To help, please paste the output of
|
Looks like querying X11 directly could be the way to go.
The returned values seem to make sense. I think the mm sizes are extrapolated from the display resolution and DPI values I've set in the desktop. |
Removing the Linux path and using the |
There is also an issue when using KDE as a desktop. KDE does not use the gsettings file and therefore nanogui does not scale with high DPI screens when using KDE. I am not sure though how to retrieve the UI scaling factor in KDE. |
@dvicini: Would you mind checking if there is a way to do this on a KDE environment? |
It's However, maybe we can just use Otherwise, we need a way of detecting things. I think the variables that need to be relied on here are the $ printenv | grep -i desktop
DESKTOP_SESSION=gnome
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
XDG_SESSION_DESKTOP=gnome
XDG_CURRENT_DESKTOP=GNOME I believe the promise that desktop managers make is to always set This approach (I believe) rules out anybody on linux who built their own window manager, though. @dvicini can you post back the output of these two commands:
This still only solves single-monitor scenarios BTW. Good enough for a hotfix for KDE though 😉 |
Hi, Thanks for the input. So I ran the commands you suggested and get
and
i don't think the dimensions from xdpyinfo really help us here. For KDE, the suggested way of scaling the display content on high dpi screens is to go through the display settings: If I change these, the dimensions output from xdpyinfo does not change (the size in millimeters is always the physical size of my screen). I also found the kreadconfig command, but I don't know how to access the display settings using that, as there does not seem to be a list of available settings? UPDATE: Delio |
I think I figured out how to detect which desktop environment is used. I changed the relevant section in screen.cpp to:
This works for me now, but it's not a very general solution, as it only works for KDE5 I guess. Should I make a pull request or are you looking for a more general solution? |
This looks reasonable. But what if |
The |
Thus
Then we can't do anything, in which case just return scale of |
How about using |
I prefer the scale factor approach. This is largely also a user choice -- a user might prefer 1.5x or 2.5x on a given screen regardless of the actual DPI value. |
Yes, the scale factor is user specific and should be accounted for, as the rest of the user interface is scaled by this factor. I will clean up the code (add nullptr check, factor out pclose) and create a pull request. |
First @wjakob, great work on this incredible library. Thank you. (This is also related to #347 ) A few weeks ago I did some work on this as I was also having trouble with scaling on a stock X11 Ubuntu 18.04. I think the problem was that Gnome itself had a bug where GLFW 3.3 had not yet been completed but forcing nanogui to use a dev 3.3 version allowed me to use their new Now that GLFW 3.3 has landed, my thinking is that something like the following could replace everything currently in
Some things to think about (and things I'm not sure of):
|
|
I'm not sure if this ends up getting the user specified "logical" DPI or the hardware DPI. The description for
Relevant GLFW ticket: glfw/glfw#1019 |
Hey @rogerdahl thanks for letting us know, this looks promising. I've been slowly iterating on updating nanogui's build system for modern cmake, it'll be a one-two punch. We've updated every other dependency, but the GLFW stuff needs to be updated with / after the new cmake stuff. I'm getting much closer. Would you be interested in taking charge of (after we update GLFW / enable external GLFW) putting together a PR to use the new GLFW method? I'll be able to help test hidpi on all three major platforms. If so, I'll CC you on the PR that will enable it. It will be a pretty big PR that we'll need lots of user testing for, but it'll give you a base that you can work from independently. |
@svenevs Sounds good. I'd be happy to help. Just give me a ping when the PR is ready. I can also help with testing on Linux and Windows. |
Awesome, thanks! I'm hoping to finish it this weekend assuming everything goes according to plan. |
Thank you for NanoGUI, it's awesome!
Are there any plans to add support for scaling on Linux? I wrote an app using NanoGUI and it uses the size passed to Screen directly as pixel size. After upgrading my monitor to 4K and increasing the OS scale factor to match, most apps and GUI elements scaled appropriately, but my NanoGUI app is now tiny...
The text was updated successfully, but these errors were encountered: