On Tue, 16 Dec 2025 07:44:53 GMT, John Hendrikx <[email protected]> wrote:
>> 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: > > Add more debug output And here is what's logged if the MT appears on the primary (scale=2) screen: Window/invalidationListener: shown changed to: true Window/invalidationListener: screen=javafx.stage.Screen@ce424859 bounds:Rectangle2D [minX=0.0, minY=0.0, maxX=1800.0, maxY=1169.0, width=1800.0, height=1169.0] visualBounds:Rectangle2D [minX=0.0, minY=40.0, maxX=1800.0, maxY=1117.0, width=1800.0, height=1077.0] dpi:151.0 outputScale:(2.0,2.0) Window/peer: setBounds(410.0, 62.0, true, true, winW:1055.0, 655.0, clientW:-1.0, -1.0, 0.0, 0.0, rsx:0.0, rsy:0.0) Window/invalidationListener: after applying bounds screen=javafx.stage.Screen@ce424859 bounds:Rectangle2D [minX=0.0, minY=0.0, maxX=1800.0, maxY=1169.0, width=1800.0, height=1169.0] visualBounds:Rectangle2D [minX=0.0, minY=40.0, maxX=1800.0, maxY=1117.0, width=1800.0, height=1077.0] dpi:151.0 outputScale:(2.0,2.0) Window/invalidationListener: output scale used before sizing scene: 2.0 Window/invalidationListener: size from scene: 773.5x730.5 Window/peer: setBounds(410.0, 62.0, true, true, winW:1055.0, 655.0, clientW:-1.0, -1.0, 0.0, 0.0, rsx:2.0, rsy:2.0) Window/invalidationListener: exit invalidation listener <img width="1167" height="767" alt="Screenshot 2025-12-16 at 10 18 51" src="https://github.com/user-attachments/assets/afa041fd-e889-49e1-8f9f-102c5a455f3e" /> If I resize the window, the layout gets fixed, though I see no output logged. Hope this helps. We also need this checked on Linux[es] ------------- PR Comment: https://git.openjdk.org/jfx/pull/2007#issuecomment-3661834417 PR Comment: https://git.openjdk.org/jfx/pull/2007#issuecomment-3661836472
