Question/feedback regarding Windows Hi DPI support and how it will affect applications
james.graham at oracle.com
Wed Feb 18 19:52:31 UTC 2015
On 2/18/2015 2:13 AM, Werner Lehmann wrote:
> Finally, it would be nice to get information about the actual screen
> DPI. In my tests Screen.getDpi always returns 96, regardless of what it
> actually is...
I'm not sure if there is a legacy API for that value in Windows
pre-Win8.1, but I know that we have been using "::GetDeviceCaps(hDC,
LOGPIXELSX)" to get our value for Screen.getDPI(). That method returns
the effective scale of a screen, which is what they want you to use to
compute a scale factor that is relative to the users preferences.
If the user chooses "I want to make things bigger or smaller on the
screen" in the Displays CP, then they can request that the default font
be 100%, 125%, 150% and sometimes 200% (and, on a Yoga Pro, they can
even ask for 300%). Depending on that setting you will see 96, 120,
144, 192, or 288 from the LOGPIXELSX/Y and you are supposed to scale
yourself by N/96.0. *NOTE* that you this setting does not change
between logout/reboots so if the user changes this setting in the CP, it
will continue to return the old information until they reboot or log out
and log back in. Then the new settings will be retrieved. (I can see
why they wouldn't want it to change dynamically when an app is running,
but I'm disappointed that they don't allow it to change when an app is
quit and restarted...)
In Win8.1 they have a new method "GetDPIForMonitor(DPI_TYPE)" where you
can ask for "Effective DPI" which is roughly the LOGPIXELSXY information
that represents "scale yourself by N/96.0", or you can ask for "Raw DPI"
which is the actual physical pixels per physical inch measurement. This
value can also change dynamically if the user modifies their Display CP
preferences. I plan to support the use of that new API soon, but it
will only be effective in Windows 8.1 or later since the API was
introduced in 8.1...
More information about the openjfx-dev