-
Notifications
You must be signed in to change notification settings - Fork 43
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
Fix HiDPI scaling on X11 and XWayland (#88) #152
base: main
Are you sure you want to change the base?
Conversation
I should warn that it does mess up the layout somewhat. Here's how the unscaled window looks on my 4K monitor: Here's the window with the scaling patch. The layout is messed up a bit, but the text is readable and everything is crisp. And here's what happens if I multiply I assume you'll know what to do, though. For me, it's not a deal breaker. |
Added a PR on Maia-Everett:wayland-hidpi for changes to allow everything to scale. It was a bit too much to add as a series of comments, since it touches 22 files in all. I am encountering one oddity, though. When I check the scaling factor being applied, I'm getting 1.5875, despite having scaling set at 1.5 in kde. Not sure where it's getting that number. |
4a04bc6
to
d82df62
Compare
I've added verbose logging for that, and it seems SDL calculates DPI based on the physical dimensions of the screen. For my primary monitor, it reports 162.56x161.3647, whereas for scaling purposes I'd want 192 DPI reported (since my desktop uses 200% scaling with 4K resolution 3840x2160). Querying the desktop environment itself will return the value we actually want. And how do you obtain the scaling value the DE uses? Lol, lmao. By using a variety of DE-specific methods of various levels of hackishness, apparently. I'll change it. |
Just curious, is there nothing in Veldrid that can be used for that? |
Unfortunately, no. Grepping For KDE specifically, my plan is to query For GNOME and other DEs, I don't know a reliable way to query fractional scaling, so we can fall back to |
Pushed new commits:
Thanks for your scaling support, @rankynbass! The PR is now feature-complete. Here's how it looks at 200% scaling in KDE: and at 150%: This fix only applies to XWayland. Native Wayland rendering when running with |
Edit: I've reverted the native Wayland commit for now because it breaks mouse input. It's still in commit history if someone wants to work on top of that. For now, you can merge the XWayland changes, and we can look at native Wayland scaling later. |
9679bab
to
53d6bab
Compare
53d6bab
to
57797fa
Compare
I've fixed the native Wayland scaling fixes and pushed them to a separate branch: Maia-Everett/XIVLauncher.Core@wayland-hidpi...Maia-Everett:XIVLauncher.Core:wayland-native-hidpi I can make a separate PR after this is merged. I'll keep this PR focused on XWayland. |
I checked under KDE Plasma 6.1 with X11, and the scaling issue is present there too, so it's not just XWayland. |
The main problem with this patch is that it doesn't have a fallback if the scale is for some reason set to 0. This can happen sometimes in flatpak; the gnome scaling may sometimes be read as 0, and then no window is shown. So in the DesktopHelpers.cs file, the individual GetXXXScaleFactor() functions should be checked to make sure that if they return a float, it is at least 1, or at the very least it should never be 0. |
// Primary monitor | ||
Log.Verbose("Obtained scale from kscreen-doctor: {0}", output.Scale); | ||
return output.Scale; |
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.
// Primary monitor | |
Log.Verbose("Obtained scale from kscreen-doctor: {0}", output.Scale); | |
return output.Scale; | |
// Primary monitor | |
if ((int)output.Scale == 0) | |
throw new System.ArgumentOutOfRangeException("kscreen-doctor returned a scale of 0 - trying other methods"); | |
Log.Verbose("Obtained scale from kscreen-doctor: {0}", output.Scale); | |
return output.Scale; |
|
||
if (match != null && match.Success) | ||
{ | ||
return float.Parse(match.Groups[1].Value); |
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.
return float.Parse(match.Groups[1].Value); | |
if (int.Parse(match.Groups[1].Value) == 0) | |
throw new System.ArgumentOutOfRangeException("gsettings returned a scale of 0 - try other methods"); | |
return float.Parse(match.Groups[1].Value); |
} | ||
catch (Exception e) | ||
{ | ||
Log.Error(e, "Cannot obtain desktop scale from gsettings - trying other methods"); |
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.
Log.Error(e, "Cannot obtain desktop scale from gsettings - trying other methods"); | |
Log.Error(e, "Cannot obtain desktop scale from xrdb - trying other methods"); |
|
||
if (match != null && match.Success) | ||
{ | ||
return int.Parse(match.Groups[1].Value) / 96f; |
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.
return int.Parse(match.Groups[1].Value) / 96f; | |
if (int.Parse(match.Groups[1].Value == 0) | |
throw new System.ArgumentOutOfRangeException("xrdb returned a scale of 0 - try other methods"); | |
return int.Parse(match.Groups[1].Value) / 96f; |
Ensure that when running with the SDL X11 driver under Wayland, the window is correctly scaled (and is crisp rather than blurry).
See #88.