On Thu, 14 Aug 2025 15:33:13 GMT, Martin Fox <[email protected]> wrote:
>> tests/system/src/test/java/test/javafx/stage/CenterOnScreenTest.java line
>> 108:
>>
>>> 106: }
>>> 107:
>>> 108: private void assertStageCentered(StageStyle stageStyle, boolean
>>> useSceneSize) {
>>
>> On Windows the size of a DECORATED or EXTENDED window includes an area
>> around the window containing the invisible drag handles. After sizeToScene
>> is called on my Windows 11 system a DECORATED or EXTENDED window will be 26
>> units wider than the scene to account for these handles (on my Mac the
>> window will be the same width as the scene).
>>
>> In this test you use a hefty delta for DECORATED windows and a smaller one
>> for EXTENDED and you use the same delta for both width and height. This is
>> causing the centerOnScreenAfterShownWithSceneSize and
>> centerOnScreenWhenShownWithSceneSize test to fail along the X axis for
>> EXTENDED stages since the delta isn't big enough.
>>
>> You might consider querying the stage for it's frame and ensure that the
>> center of the frame is where you expect it rather than make any assumptions
>> about how the scene width relates to the window width.
>
> The test still looks incorrect. You're passing in posX and posY as the
> tolerance deltas.
>
> I'm not sure what you're testing here. There's an internal algorithm that
> sets the window's x and y coordinate to center it. You're replicating that
> algorithm here and testing whether the window has the same x and y values. If
> you're concerned that the platform code didn't actually move the window you
> would need to use a robot to sample a pixel and verify that the window is
> where you expect. Or was there some other centering problem you saw on Linux?
On Linux, when frame extents are received (and it might arrive later depending
on the compositor / window manager), it must do a correction on the centering
accounting the decorations (glass_window.cpp around line 895). This was the
idea behind the test, but I think I "over tested" and this is really not
useful. Will remove it.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1789#discussion_r2294785923