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

Harshitha Onkar honkar at openjdk.org
Tue Jan 21 20:20:36 UTC 2025


On Tue, 21 Jan 2025 19:03:02 GMT, Alisen Chung <achung at openjdk.org> wrote:

> The question is when the coordinate lands out of bounds of all screens, especially in cases where it would be reasonable to clamp to either screen, what should the behavior be? We discussed a few options:
> 
> 1. we could look for the closest screen in the x direction, then y direction and clamp on that screen using x and y
> 2. we could look for the closest screen in both directions by calculating absolute distance then clamp on that screen using x and y
> 3. we could travel to the location and calculate the slope to figure out where to stop (basically “fly” there and once you hit a wall you stop)
> Currently on macOS the mouse tries to “fly” over to the location and moves along the first wall it encounters, so a combination of 2 and 3. The problem I could see with this approach is that it relies not only on the final location but also the starting location, so a mouseMove to the same location would have different behaviors depending on where you started. I’m not sure if this is a problem but @aivanov-jdk and @honkar-jdk do you have any thoughts/opinions?

The approach which results in the same and consistent behavior irrespective of the starting location sounds better to me. If we go with the 1st approach, does it result in consistent behavior (i.e does it return the same screen irrespective of the starting point) ?

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

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


More information about the client-libs-dev mailing list