RFR: 8345538: Robot.mouseMove doesn't clamp bounds on macOS when trying to move mouse off screen [v3]
Alexey Ivanov
aivanov at openjdk.org
Fri Dec 20 20:46:36 UTC 2024
On Fri, 20 Dec 2024 20:42:05 GMT, Harshitha Onkar <honkar at openjdk.org> wrote:
>>> For me, the test _without the fix_ prints
>>>
>>> ```
>>> Current mouse location: java.awt.Point[x=0,y=200]
>>> ```
>>>
>>> The mouse cursor moves to 200, 200 and then to 0, 200 on the screen.
>>
>>
>> What platform ? Alisen did say in the description that Windows & Linux clamp which presumably is either something elsewhere in the JDK implementation, or just how the platform works. I looked (briefly) at Linux and we just pass the values to XWarpPointer so I assumed it was the platform ..
>
> In MouseInfo.getPointerInfo()
> The point is updated here [fillPointWithCoords()](https://github.com/openjdk/jdk/blob/7ba969a576eb92446e40587fecf98e1e4aba8883/src/java.desktop/share/classes/java/awt/MouseInfo.java#L72) .
>
> and what follows after
>
>
> for (int i = 0; i < gds.length; i++) {
> GraphicsConfiguration gc = gds[i].getDefaultConfiguration();
> Rectangle bounds = gc.getBounds();
> if (bounds.contains(point)) {
> // checks if the point updated by fillPointWithCoords
> // is within the bounds of any of the screen device else it returns null
> retval = new PointerInfo(gds[i], point);
> }
> }
I ran it on Windows, sorry I should've said it explicitly.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22781#discussion_r1894374867
More information about the client-libs-dev
mailing list