RFR: 8346281: [Windows] RenderScale doesn't update to HiDPI changes [v2]

Kevin Rushforth kcr at openjdk.org
Fri Nov 7 21:52:19 UTC 2025


On Thu, 6 Nov 2025 21:43:32 GMT, Jose Pereda <jpereda at openjdk.org> wrote:

>> This PR adds the missing native implementation for Windows, `GlassWindow::HandleDPIEvent`, to notify the (Java) window when there is a DPI change event, which can happen when the user changes the resolution of the screen (via Settings -> System -> Display -> scale), while the JavaFX application is running, in a similar way as Java Desktop [handles](https://github.com/openjdk/jdk/blob/master/src/java.desktop/windows/native/libawt/windows/awt_Window.cpp#L1418) this DPI event.
>> 
>> When such `WM_DPICHANGED` event happens, `GlassWindow::HandleDPIEvent` notifies the (Java) window, which changes its platform scale via `Window::notifyScaleChanged`, and `GlassScreen::HandleDisplayChange();` is needed too, to update the platform scale of the screen where the window is at as well.
>> 
>> The change in `Screen:: notifySettingsChanged` is needed in order to prevent disposing screens that are not referenced by windows, and only do it when the screen instance of a given window does change.
>> 
>> There are no tests added to this PR, since these would require manual intervention to change the resolution of the display. In any case, the test case added to the [issue](https://bugs.openjdk.org/browse/JDK-8346281) runs fine now when the app runs on a given screen and the user changes its resolution. It has also been tested that it doesn't have any side effect on macOS.
>> 
>> For the case when the app runs on a different display that the one that was changed, see https://bugs.openjdk.org/browse/JDK-8371302 and a possible fix with https://github.com/openjdk/jfx/pull/1963.
>
> Jose Pereda has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Use set and remove unnecessary casting

All my testing is good. It fixes the bug and as far as I can tell, doesn't introduce new regressions.

My only question is that I'm still not sure why the changes in the shared code in Screen.java are needed.

modules/javafx.graphics/src/main/java/com/sun/glass/ui/Screen.java line 403:

> 401:         for (Screen screen : oldScreens) {
> 402:             screen.dispose();
> 403:         }

I'm still a little puzzled as to why a change was needed in the class at all. Even with the change you made to the native Windows glass code, it seems that calling dispose for all of the old Java screen objects is what we want. Am I missing something?

-------------

PR Review: https://git.openjdk.org/jfx/pull/1964#pullrequestreview-3436557419
PR Review Comment: https://git.openjdk.org/jfx/pull/1964#discussion_r2505645025


More information about the openjfx-dev mailing list