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:09:37 UTC 2024
On Fri, 20 Dec 2024 19:48:24 GMT, Phil Race <prr at openjdk.org> wrote:
>> Is the current behaviour even a bug? [`Robot.mouseMove`](https://docs.oracle.com/en/java/javase/23/docs/api/java.desktop/java/awt/Robot.html#mouseMove(int,int)) says nothing about invalid coordinates.
>>
>>> @aivanov-jdk I see your point. But I'm running into NPE at `MouseInfo.getPointerInfo().getLocation()` without the fix as well (dual monitor, extended display setup)
>>
>> It's probably even better…
>>
>>> Is it expected of MouseInfo.getPointerInfo() to return null for off-screen coordinates (meaning does it consider it as mouse not available if it is outside the screen devices)?
>>>
>>> PointerInfo has two things associated with it - screen device and a location, so if it is not able to associate the coordinate with any of the screen device (off-screen coordinate) is it suppose to return null in this case?
>>
>> So, the mouse seems to be positioned outside of the virtual screen bounds. For this reason, `MouseInfo.getPointerInfo()` cannot return anything.
>>
>> This again raises the question, why does it return a non-null value on macOS?
>>
>> What do you see on the screen? Does the mouse cursor or its part remain visible on the screen? What happens when you start moving your mouse?
>
>> Yes, I'm running into NPE without as well as with the fix.
>
> Can you provide information on your multi-screen setup ?
> how many displays ? what is the relative placement of the monitors ?
> What are the virtual bounds of your setup ?
>
> And the stack trace of the exception you get too.
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.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22781#discussion_r1894348877
More information about the client-libs-dev
mailing list