On Tue, 17 Dec 2024 20:46:54 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 incrementally with one additional 
> commit since the last revision:
> 
>   fixed test to fail before fix and pass after fix

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

> 39:         robot.mouseMove(200, 200);
> 40:         robot.delay(500);
> 41:         robot.mouseMove(20000, 200);

Adds more clarity if you declare the off screen location as follows:


 private static final Point OFF_SCREEN_LOC = new Point(20000, 200);
 ....
 robot.mouseMove(OFF_SCREEN_LOC.x , OFF_SCREEN_LOC.y);
  .....
 currLoc.equals(OFF_SCREEN_LOC)

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

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

Reply via email to