RFR: 8345538: Robot.mouseMove doesn't clamp bounds on macOS when trying to move mouse off screen [v3]
Harshitha Onkar
honkar at openjdk.org
Fri Dec 20 18:23:36 UTC 2024
On Fri, 20 Dec 2024 13:59:40 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>> test/jdk/java/awt/Robot/MouseMoveOffScreen.java line 44:
>>
>>> 42: robot.delay(500);
>>> 43:
>>> 44: Point currLoc = MouseInfo.getPointerInfo().getLocation();
>>
>> Not directly related to this change, `MouseInfo.getPointerInfo().getLocation()` throws NPE for a multi-monitor extended display setup on windows for an off-screen location (I haven't checked on other platforms). It returns valid PointerInfo only if the point falls within the bounds of any of the screen device , else it returns null. This may be the expected behavior of MouseInfo.getPointerInfo() but the javadoc is not clear about how off-screen coordinates are handled.
>>
>> For this test you can add a null check before calling .getLocation() for sanity (although multimonitor setup is not the case for CI runs)
>
>> For this test you can add a null check before calling .getLocation() for sanity (although multimonitor setup is not the case for CI runs)
>
> If `Robot.mouseMove` is expected to limit mouse to the valid (virtual screen) coordinates, `MouseInfo.getPointerInfo()` should never throw `NullPointerException` if mouse is available.
@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)
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?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22781#discussion_r1894251274
More information about the client-libs-dev
mailing list