On Mon, 27 Oct 2025 14:44:44 GMT, John Hendrikx <[email protected]> wrote:
>> This new check is much more accurate to detect whether a parent is currently >> laying out its children. The previous code almost never worked, resulting in >> additional unnecessary layouts. > > John Hendrikx has updated the pull request incrementally with one additional > commit since the last revision: > > Rename test Update on previous reply: I did some more investigation into how Scenes are sized. In Window there is a huge invalidation listener when its showing state is invalidated. It sets up the bounds and render scale of its peer, does an initial sizing of the scene, etcetera. Now, the order of operations here is causing a slight issue. Basically what happen is: - Window is created but not visible - Default location is somewhere on a scale=2 screen (even though the X value is already set on the Stage to be on a different screen) - Window is shown, triggering the invalidation listener - The render scale (still 2.0) is set on the peer - For new windows, a "sizeToScene" type code is called on the Scene - This does layout calculations with render scale=2 - The invalidation listener then proceeds to adjust the size and position of the Window peer - This calls `applyBounds` which discovers the peer is on an entirely different screen, triggering a render scale change to 1.0 - The render scale change doesn't trigger much of anything - The invalidation listener (still the same callback) continues and calls `applyBounds` again - It exits without doing anything further (scene is not resized again) So to summarize: - Scene is sized **before** it is moved to the correct location (which may be a different screen) - Only after it is sized, it is discovered a different render scale should be in effect - No action is taken to adjust the scene size, scene stays sized incorrectly Quick fix I found: - Call `applyBounds` before setting the renderscale on the peer or sizing the scene - The problem is now gone **AND** for an outside observer on RenderScale property it never changes from 1.0 -> 2.0 -> 1.0 ------------- PR Comment: https://git.openjdk.org/jfx/pull/1945#issuecomment-3651100681
