RFR: 8299968: Second call to Stage.setScene() create sizing issue with uiScale > 1.0 [v4]
Lukasz Kostyra
lkostyra at openjdk.org
Mon Mar 13 14:58:53 UTC 2023
> Issue happened during setting a new Scene - updating a new View was done while the Window reference it kept was null. This caused it to default scaling values to 1.0f (or 100%) while processing a resize notification, which for high DPI screens with scaling different than 100% caused UI issues.
>
> Resolved by splitting `_setView()` native call into two parts - first one sets the view, then back in JVM side we set a correct Window reference, then we trigger the notification. It has to be triggered from native side, because Windows backend of Glass sends back new width/height pulled from WinAPI `::GetClientRect()` call.
>
> In process of working on this issue I also found another scenario causing the same problem - calling `Stage.setScene()` after `Stage.show()`. The patch fixed that case as well.
>
> Added a system test which is supposed to check for above issues. I didn't limit it to run only on platforms with UI scaling enabled because it also serves as a good sanity check in case there are some other changes to code that might move/scale the UI unwantingly. I tested this patch both on macOS Ventura and Windows 11, with `d9c091f` all tests pass while without `d9c091f` on Windows tests `testShowAndSetScene` and `testSecondSetScene` fail as expected.
Lukasz Kostyra has updated the pull request incrementally with two additional commits since the last revision:
- SetSceneScalingTest: Address review issues
- Calculate robot.mouseMove coords based on Stage/Scene position
- Use stage.setOnShown() instead of addEventListener()
- GlassWindow: Fix Copy-Paste's Error with unnecessary View variable
-------------
Changes:
- all: https://git.openjdk.org/jfx/pull/1054/files
- new: https://git.openjdk.org/jfx/pull/1054/files/3e152cb8..4701dee6
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jfx&pr=1054&range=03
- incr: https://webrevs.openjdk.org/?repo=jfx&pr=1054&range=02-03
Stats: 12 lines in 2 files changed: 4 ins; 4 del; 4 mod
Patch: https://git.openjdk.org/jfx/pull/1054.diff
Fetch: git fetch https://git.openjdk.org/jfx pull/1054/head:pull/1054
PR: https://git.openjdk.org/jfx/pull/1054
More information about the openjfx-dev
mailing list