RFR: 8373688: Wrong render scale is used if Window is on another screen when Scene is sized [v4]
John Hendrikx
jhendrikx at openjdk.org
Sun Dec 21 15:12:43 UTC 2025
> When a Window is created with a certain X/Y coordinate to place it on a specific screen, and is subsequently shown for the first time, one of the first things it does is size the window according to the size of the Scene. It does this based on the render scale of the *primary* screen as it has not moved the peer yet to the correct screen. After the scene has been sized, it is moved to the correct screen, triggering a change of render scale, but not a resizing of the Window (as this is only done once).
>
> The result of this is that due to slight difference in render scale, the size calculated for the scene may be a few pixels off. As the scene's preferred size is used for this calculation, even a few pixels too small can result in Labels being shown with ellipsis on the intended target screen with a different render scale.
>
> When observing the render scale X or Y property, one can observe a change from 1.0 (the default value) to 2.0 (the primary screen's render scale) to another value (depending on the target screen). However, the Window involved (being positioned by the user using setX()/setY() before it is shown) was never shown on the primary screen, yet the size calculation assumed it was.
>
> To solve this problem, the peer should be moved to the correct screen **before** asking the Scene for its preferred size to use as the initial Window size. Doing so (by adding an additional `applyBounds` call) also results in the render scale properties to only change once (or not at all) from their default value to the target screen's value (or not at all if the target screen is 1.0 scale).
John Hendrikx has updated the pull request incrementally with one additional commit since the last revision:
Only resize scene if one (or both) dimension are not set explicitly
-------------
Changes:
- all: https://git.openjdk.org/jfx/pull/2007/files
- new: https://git.openjdk.org/jfx/pull/2007/files/dc02573a..d66e6abf
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jfx&pr=2007&range=03
- incr: https://webrevs.openjdk.org/?repo=jfx&pr=2007&range=02-03
Stats: 19 lines in 1 file changed: 17 ins; 2 del; 0 mod
Patch: https://git.openjdk.org/jfx/pull/2007.diff
Fetch: git fetch https://git.openjdk.org/jfx.git pull/2007/head:pull/2007
PR: https://git.openjdk.org/jfx/pull/2007
More information about the openjfx-dev
mailing list