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

Alisen Chung achung at openjdk.org
Tue Dec 17 20:03:37 UTC 2024


> Currently on macOS when mouseMove is given an offscreen coordinate to move the mouse to, mouseMove will physically clamp to the edge of the screen, but if you try to grab the mouse location immediately after by using MouseInfo.getPointerInfo().getLocation() you will get the value of the offscreen point.
> 
> Windows and linux do this clamping and coordinate handling for us, but new distributions may not necessarily handle clamping the same way, so Robot should be checking for clamping rather than delegating it to native.
> 
> This fix updates shared code to cache the screen bounds and adds a check to not exceed the bounds in mouseMove. The caching is done in the Robot constructor, so if the screen bounds changes the constructor must be called again to update to the new bounds.

Alisen Chung has updated the pull request incrementally with one additional commit since the last revision:

  add test, remove comment

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/22781/files
  - new: https://git.openjdk.org/jdk/pull/22781/files/effa0f05..62e7dede

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=22781&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=22781&range=00-01

  Stats: 50 lines in 2 files changed: 49 ins; 1 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/22781.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/22781/head:pull/22781

PR: https://git.openjdk.org/jdk/pull/22781


More information about the client-libs-dev mailing list