RFR: 8286581: Make Java process DPI Aware if sun.java2d.dpiaware property is set [v2]
Alexey Ivanov
aivanov at openjdk.org
Tue Jan 17 20:10:34 UTC 2023
On Tue, 17 Jan 2023 19:43:40 GMT, Phil Race <prr at openjdk.org> wrote:
> Can you explain why you think this change is needed if its already set ?
Initially, I proposed to remove the property and code associated with it because its value isn't respected as the DPI Awareness is set in the manifest.
You [asked](https://bugs.openjdk.org/browse/JDK-8286581?focusedCommentId=14495409&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14495409) about a custom launcher which may not set the DPI Awareness in the manifest.
If the manifest entries are missing, Java calls [`SetProcessDPIAware`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setprocessdpiaware) which sets the process DPI Awareness to **System** (`DPI_AWARENESS_CONTEXT_SYSTEM_AWARE`). That is the UI on the _main screen_ is rendered as expected. Yet if the user changes the scale of the main screen or moves the window to a monitor with different scale, the UI will be auto-scaled by Windows, which means it will be blurry.
Java supports **Per-Monitor v2 DPI Awareness** (`DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2`). This fix addresses the difference and sets the DPI Awareness to the correct one in case if the manifest entries are missing for whatever reason.
> And additionally, you describe what happens with explicit setting of the property (when the manifest is disabled) but don't say which is the default.
The default value is `true` for the standard launcher.
https://github.com/openjdk/jdk/blob/ade08e190cc28cf0ce0194fa3fb67e48dc634e07/src/java.desktop/windows/classes/sun/java2d/windows/WindowsFlags.java#L220-L223
-------------
PR: https://git.openjdk.org/jdk/pull/11998
More information about the client-libs-dev
mailing list