On Wed, 30 Apr 2025 21:13:12 GMT, Alisen Chung <ach...@openjdk.org> wrote:

>> Currently on macOS when mouseMove is given an offscreen coordinate to move 
>> the mouse to, mouseMove will physically clamp to the edge of the screen, but 
>> if you try to grab the mouse location immediately after by using 
>> MouseInfo.getPointerInfo().getLocation() you will get the value of the 
>> offscreen point.
>> 
>> Windows and linux do this clamping and coordinate handling for us, but new 
>> distributions may not necessarily handle clamping the same way, so Robot 
>> should be checking for clamping rather than delegating it to native.
>> 
>> This fix updates shared code to cache the screen bounds and adds a check to 
>> not exceed the bounds in mouseMove. The caching is done in the Robot 
>> constructor, so if the screen bounds changes the constructor must be called 
>> again to update to the new bounds.
>
> Alisen Chung has updated the pull request with a new target base due to a 
> merge or a rebase. The pull request now contains 17 commits:
> 
>  - Merge branch 'master' of https://github.com/openjdk/jdk into 8345538
>  - move clamping code into macos
>  - use absolute distance to choose correct screen for offscreen clamping
>  - helper function
>  - grab screen data on mouseMove
>  - fix bounds
>  - peer.mouseMove
>  - fix implementation
>  - robot update
>  - Revert "robot multimonitor fix"
>    
>    This reverts commit 5734165881a66dc48d5a9f19e02bf63fac57cdc9.
>  - ... and 7 more: https://git.openjdk.org/jdk/compare/8b16897b...e0a5c872

test/jdk/java/awt/Robot/MouseMoveOffScreen.java line 52:

> 50:         for (int i = 0; i < gs.length; i++) {
> 51:             r[i] = gs[i].getDefaultConfiguration().getBounds();
> 52:         }

@alisenchung 
I would suggest logging screen bounds (provides better debug info for anyone 
running the test)

Suggestion:

        for (int i = 0; i < gs.length; i++) {
            r[i] = gs[i].getDefaultConfiguration().getBounds();
            System.out.println("Screen: "+ gs[i].getIDstring() + "  Bounds: " + 
r[i]);
        }

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22781#discussion_r2109774604

Reply via email to