Skip to content

Windows: Improve DPI scaling on modern OS versions - #19387

Open
Ryunam wants to merge 1 commit into
libretro:masterfrom
Ryunam:windows-dpi-fix
Open

Windows: Improve DPI scaling on modern OS versions#19387
Ryunam wants to merge 1 commit into
libretro:masterfrom
Ryunam:windows-dpi-fix

Conversation

@Ryunam

@Ryunam Ryunam commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Description

In the current RetroArch master on Windows, the DPI metrics used for scaling widgets and UI elements for certain menu drivers (Ozone and MaterialUI) are based on the physical size/resolution of the screen (HORZRES and HORZSIZE), calculated through the GetDeviceCaps() function. This calculation does not take into account the user-defined DPI scaling as set in Windows itself.

As a consequence of this, when using RA on a Windows device that might be connected to 2+ screens having the same resolution but different DPI values (such as in my use-case, an handheld PC with a 7-inch 1080p internal screen that is occasionally docked to a bigger 1080p screen), the UI scaling will end up differing greatly between one screen and another.
This forces users to adjust the scaling factor in the menu every single time the screen is switched around...

This PR proposes a more accurate form of DPI awareness, derived from the shcore.dll library and the GetScaleFactorForMonitor() function. On Windows versions 8.1 and above, this lets us calculate the DPI value that was actually set for the chosen monitor in the OS, preserving the UI scale between same-res screens with different DPI values.
The original GetDeviceCaps() method is kept as a fallback approach for older Windows systems, where the shcore library or the newer DPI awareness systems might not be available (Windows 7 and below).

Reviewers

@LibretroAdmin

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