RFR: 8345538: Robot.mouseMove doesn't clamp bounds on macOS when trying to move mouse off screen [v11]

Sergey Bylokhov serb at openjdk.org
Mon May 5 22:48:20 UTC 2025


On Mon, 5 May 2025 19:23:49 GMT, Phil Race <prr at openjdk.org> wrote:

> (we) looked at the code that was reporting the off-screen mouse position several weeks ago.
> What we are doing seems to correspond to all the suggestions on the internet as to how to get mouse position on macOS.
> I didn't spot any obvious alternative.

Previously, we used a different method, which might behave differently (It also used a different thread):
https://github.com/openjdk/jdk/commit/eea06f70fc6154be12d066df6669e7c6d8c0bc09#diff-698576e56937835cfc553bbd97fe12fabf954e0a20e7b9c3bfc3a77763fb6bd0L123

I propose developing a native reproducer to investigate the mouse position clamping behavior observed on macOS. The steps would include:
1. Moving the mouse cursor outside the screen bounds.
2. Retrieving the current mouse position.
3. Simulating a mouse click at the current position.
4. Retrieving the mouse position again.
5. Comparing the positions from steps 2 and 4.

If the positions differ, we can ask Apple on the following points:
1. Is the clamping of the mouse position during a click an intentional behavior or a bug?
2. If intentional, what is the recommended method for applications to replicate this clamping behavior?
3. If it is a feature intended to be used by certain applications, should we consider bypassing this behavior in the JDK?

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

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


More information about the client-libs-dev mailing list