Skip to content

Prefer Xft.dpi for fractional Linux DPI scaling - #11

Open
ElCruncharino wants to merge 1 commit into
enzo1982:masterfrom
ElCruncharino:fractional-linux-dpi-scaling
Open

Prefer Xft.dpi for fractional Linux DPI scaling#11
ElCruncharino wants to merge 1 commit into
enzo1982:masterfrom
ElCruncharino:fractional-linux-dpi-scaling

Conversation

@ElCruncharino

@ElCruncharino ElCruncharino commented Jul 10, 2026

Copy link
Copy Markdown

Problem

GetSurfaceDPI() on Linux only ever derived an integer scale factor (via gdk_screen_get_monitor_scale_factor or the GDK_SCALE env 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 the Xft.dpi X resource via XResourceManagerString(). 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant