On Sun, 15 Nov 2026 05:10:43 GMT, Sendao Yan <[email protected]> wrote:

>> On macOS 27 window animation takes a bit longer and if we attempt to perform 
>> the mouse event on the window at this moment the coordinates conversion can 
>> be incorrect. Uncommenting the one second delay before mouse click fixing 
>> the problem.
>> 
>> 
>> 
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> test/jdk/java/awt/event/MouseEvent/FrameMouseEventAbsoluteCoordsTest/FrameMouseEventAbsoluteCoordsTest.java
>  line 79:
> 
>> 77:             robot.mouseMove(mousePositionAbsolute.x,
>> 78:                             mousePositionAbsolute.y );
>> 79:             robot.delay(1000);
> 
> **[suggestion] Consider moving the delay ahead of the coordinate computation**
> 
> As written, the delay sits between `mouseMove()` and `mousePress()`, so 
> `button.getLocationOnScreen()` and the `mouseMove()` itself still execute 
> while the window may be in the middle of the show animation — only the press 
> is deferred. That is consistent with the failure in the bug (the absolute 
> screen-coordinate check passed; only the component-relative conversion was 
> off), so this does fix the reported problem.
> 
> Still, moving the delay to right after `setAutoWaitForIdle(true)` would be 
> strictly more robust and easier to reason about: both the geometry read and 
> the mouse interaction would then happen only after the animation has settled, 
> so the fix no longer depends on the window's screen position being stable 
> while it animates. The cost is identical.
> 
> 
> robot = new Robot();
> robot.setAutoWaitForIdle(true);
> robot.delay(1000);          // let the macOS window show animation settle
> mousePositionAbsolute = new Point(button.getLocationOnScreen().x + 
> button.getWidth()/2,
>                                   button.getLocationOnScreen().y + 
> button.getHeight()/2);
> mousePosition = new Point(button.getWidth()/2,
>                           button.getHeight()/2);
> robot.mouseMove(mousePositionAbsolute.x,
>                 mousePositionAbsolute.y);
> robot.mousePress(InputEvent.BUTTON1_MASK);
> 
> 
> Not blocking — the current placement is fine if you prefer the minimal diff.

> [@sendaoYan](https://github.com/sendaoYan) please do not use AI to create 
> comments in PRs.
> 
> The OpenJDK AI interim policy explicitly forbids it. You may end up tainting 
> the entire PR for other people.
> 
> The policy at https://openjdk.org/legal/ai is
> 
> Q 7. Is it okay to use a generative AI tool to review draft JEPs, JavaDoc, or 
> other documents, so long as I write all of the text myself? A 7. Yes. This is 
> clearly a case of using a generative AI tool to review content, which is fine.
> 
>  The key part is “**so long as I write all of the text myself”**.
> 
> So do not paste even a single word out of AI into github PRs (or JBS bugs).  
> Instead, read what it says, understand it, then write your own words in your 
> own way.  Not bullet by bullet but from scratch.  Of course there’ll be 
> plenty of times when there’s only one way to say something but at least 
> you’ll know you didn’t copy+paste.

Sorry for that. I won't do it anymore. Sorry.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/33910#discussion_r4594116263

Reply via email to