-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Resolve #21494: Automatically set window scaling based on DPI #21907
Conversation
Check DPI at UiContext load if not previously checked, then set to reasonable division of 0.25.
49ad833
to
565ed5e
Compare
@karstenvanf Could you apply the requested changes? |
This pull request has been marked as stale and will be closed in 14 days if no action is taken. To keep it open, leave a comment or remove the |
This pull request has been marked as stale and will be closed in 14 days if no action is taken. To keep it open, leave a comment or remove the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've rebased and updated this PR. The initial implementation used SDL_GetDisplayDPI
, which was producing unreliable results on macOS, and apparently is also discouraged by SDL.
Instead, I've changed the implementation to use SDL_GetWindowSize
and SDL_GetRendererOutputSize
instead, as recommended by SDL. This infers the scaling ratio from the actual canvas size vs the one requested. This appears to work well for me.
Could someone test this works as expected on Windows as well?
@Basssiiie Pushed a fix to take cases into account where |
@AaronVanGeffen Tested the newest build and no crashes anymore. The game looks the same as develop now. I wonder what the returned error code was. 😅 |
In the current code, I can't be certain, but here's the enum from
I'm guessing it was returning |
I used a similar to solution to #6991, but modified it to include a config option that flags whether the DPI has been checked instead of setting an invalid scaling factor. If the DPI check returns an error, it does not change from the default of 1.