RFR: 8345538: Robot.mouseMove doesn't clamp bounds on macOS when trying to move mouse off screen [v11]
Alexander Zvegintsev
azvegint at openjdk.org
Thu Mar 13 16:31:19 UTC 2025
On Mon, 3 Feb 2025 17:22:19 GMT, Alexander Zvegintsev <azvegint at openjdk.org> wrote:
>> Alisen Chung has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - helper function
>> - grab screen data on mouseMove
>
> src/java.desktop/share/classes/java/awt/Robot.java line 258:
>
>> 256:
>> 257: if (leastXDiff > leastYDiff) {
>> 258: peer.mouseMove(finX2, finY2);
>
> Let's say I have the following display configuration on Linux. Since it uses Xinerama, it shares the same coordinate system.
>
> java.awt.Rectangle[x=0,y=0,width=3440,height=1440]
> java.awt.Rectangle[x=3440,y=0,width=1440,height=2560]
>
> 
>
> When I try to move the mouse to `x=20000,y=200`, I see that it clamps to `x=3439,y=200` (a point between 2 screens), while before it was `x=4879,y=200`(a rightmost point).
>
> The old behavior seems more logical to me.
Here are a few cases where it still seems to fail after the update:
Title: secondary above the primary
Cmd: xrandr --output DP-0 --primary --pos 0x1440 --rotate normal --preferred --output DP-2 --pos 0x0 --rotate normal --preferred
screen #0 java.awt.Rectangle[x=0,y=1440,width=3440,height=1440]
screen #1 java.awt.Rectangle[x=0,y=0,width=2560,height=1440]
x 20000 y 200 [moving to]
- x 2559 y 200 [actual location] # before fix
+ x 3439 y 1440 [actual location] # after fix
---
Title: primary above the secondary, right side aligned
Cmd: xrandr --output DP-0 --primary --pos 0x0 --rotate normal --preferred --output DP-2 --pos 880x1440 --rotate normal --preferred
screen #0 java.awt.Rectangle[x=0,y=0,width=3440,height=1440]
screen #1 java.awt.Rectangle[x=880,y=1440,width=2560,height=1440]
x 200 y 20000 [moving to]
- x 200 y 1439 [actual location]
+ x 880 y 2879 [actual location]
---
Title: secondary above the primary, right side aligned
Cmd: xrandr --output DP-0 --primary --pos 0x1440 --rotate normal --preferred --output DP-2 --pos 880x0 --rotate normal --preferred
screen #0 java.awt.Rectangle[x=0,y=1440,width=3440,height=1440]
screen #1 java.awt.Rectangle[x=880,y=0,width=2560,height=1440]
x -20000 y 200 [moving to]
- x 880 y 200 [actual location]
+ x 0 y 1440 [actual location]
x 200 y -20000 [moving to]
- x 200 y 1440 [actual location]
+ x 880 y 0 [actual location]
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22781#discussion_r1993898584
More information about the client-libs-dev
mailing list