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

I am testing on macOS 26.1 with this PR merged with the latest master branch.

Here is what I see when the MT shows up on the secondary (scale=1) monitor:


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(459.0, -1437.0, true, true, winW:1165.0, 880.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@5fd7eb71 bounds:Rectangle2D [minX=-760.0, 
minY=-1440.0, maxX=1800.0, maxY=0.0, width=2560.0, height=1440.0] 
visualBounds:Rectangle2D [minX=-760.0, minY=-1440.0, maxX=1800.0, maxY=0.0, 
width=2560.0, height=1440.0] dpi:108.0 outputScale:(1.0,1.0)
Window/invalidationListener: output scale used before sizing scene: 1.0
Window/invalidationListener: size from scene: 791.0x726.0
Window/peer: setBounds(459.0, -1437.0, true, true, winW:1165.0, 880.0, 
clientW:-1.0, -1.0, 0.0, 0.0, rsx:1.0, rsy:1.0)
Window/invalidationListener: exit invalidation listener


<img width="1233" height="948" alt="Screenshot 2025-12-16 at 10 16 42" 
src="https://github.com/user-attachments/assets/45e35016-46f2-44e3-908e-048d6f5eb109";
 />

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

PR Comment: https://git.openjdk.org/jfx/pull/2007#issuecomment-3661822951

Reply via email to