Prefer Xft.dpi for fractional Linux DPI scaling - #11
Open
ElCruncharino wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
GetSurfaceDPI()on Linux only ever derived an integer scale factor (viagdk_screen_get_monitor_scale_factoror theGDK_SCALEenv var). On desktops using fractional scaling (e.g. 1.75x, common on KDE/GNOME HiDPI setups), this either rounds to the nearest integer (making the UI noticeably too large or too small) or fails entirely under Flatpak sandboxing, where GDK's monitor-scale detection can't see the compositor's scale at all - resulting in the UI rendering at 1x regardless of the actual display scale.Fix
Adds
BackendXLib::QueryXftDPI(), which reads theXft.dpiX resource viaXResourceManagerString(). This is the desktop-independent mechanism used by GNOME, KDE and XFCE alike to communicate display DPI to legacy toolkits. It already supports fractional values, and - unlike the GDK monitor scale factor - remains available to sandboxed applications (e.g. Flatpak) that only have access to the X11 socket, since it requires no filesystem or GTK theme access.This value is now preferred over the integer GDK-based detection in both the cairo and plain xlib surface backends.
Testing
Verified visually on KDE Plasma (Wayland session, XWayland client) at 1.75x scale - the UI now renders at the correct scale instead of rounding to 2x.