On Fri, 28 Feb 2025 03:51:55 GMT, Sergey Bylokhov <s...@openjdk.org> wrote:

> To some extent, yes, but the Robot class is part of AWT, which is a 
> platform-dependent toolkit.

The main problem we are trying to solve with this fix is that macOS behavior is 
incorrect in that it just reflects whatever value it was passed as the 
destination point for mouseMove.

If we set mouseMove to go to (10000,10000) and call 
MouseInfo.getPointerInfo().getLocation(), that then calls the native 
CGEventGetLocation which returns the (10000,10000) point, but the mouse pointer 
is still visible in the bottom right corner of the screen.

On Windows, the native API called is GetCursorPos, which does return the 
correct location of the mouse.

If we don’t clamp the mouse pointer to a screen, then there can’t be a good 
return value for getLocation() (note that the API spec for 
PointerInfo.getLocation() only allows returning null if there's no mouse). So 
we can’t just defer the behavior to the platform, clamping needs to be added 
somewhere in the JDK code.

We could add the clamping code in a few places:
1. In robot shared code
2. In CRobot macOS code
3. In MouseInfo.getPointerInfo().getLocation()

Do you have any opinions on where the code should be?

-------------

PR Comment: https://git.openjdk.org/jdk/pull/22781#issuecomment-2722616951

Reply via email to