RFR: 8345538: Robot.mouseMove doesn't clamp bounds on macOS when trying to move mouse off screen [v5]
Harshitha Onkar
honkar at openjdk.org
Fri Jan 24 00:25:15 UTC 2025
On Thu, 23 Jan 2025 23:46:04 GMT, Alisen Chung <achung at 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:
>
> robot multimonitor fix
src/java.desktop/share/classes/java/awt/Robot.java line 269:
> 267: * <p>
> 268: * It is allowed to use only a combination of valid values as a {@code buttons} parameter.
> 269: * A valid combination consists of {@code InputEvent.BUTTON1_DOWN_MASK},
Spacing looks off here as well.
src/java.desktop/share/classes/java/awt/Robot.java line 323:
> 321: *
> 322: * @param buttons the Button mask; a combination of one or more
> 323: * mouse button masks.
Spacing looks off on javadocs
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22781#discussion_r1927916121
PR Review Comment: https://git.openjdk.org/jdk/pull/22781#discussion_r1927915281
More information about the client-libs-dev
mailing list