On Tue, 28 Jan 2025 04:43:44 GMT, Alisen Chung <ach...@openjdk.org> wrote:
>> 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 three additional > commits since the last revision: > > - robot update > - Revert "robot multimonitor fix" > > This reverts commit 5734165881a66dc48d5a9f19e02bf63fac57cdc9. > - Revert "init finX, finY" > > This reverts commit 0eb4226fe6d3cf7406bf0124d4871388fb04a77e. Changes requested by aivanov (Reviewer). src/java.desktop/share/classes/java/awt/Robot.java line 234: > 232: for (Rectangle screenBounds : allScreenBounds) { > 233: int closestX = Math.min(Math.max(x, screenBounds.x), > screenBounds.x + screenBounds.width); > 234: int closestY = Math.min(Math.max(y, screenBounds.y), > screenBounds.y + screenBounds.height); I propose moving the code which calculates the closest — _final_ — position of the mouse to a helper method, it would make the logic cleaner. src/java.desktop/share/classes/java/awt/Robot.java line 242: > 240: mouseMove(x,y); > 241: afterEvent(); > 242: return; So, now you recursively call `mouseMove` again… ------------- PR Review: https://git.openjdk.org/jdk/pull/22781#pullrequestreview-2579171240 PR Review Comment: https://git.openjdk.org/jdk/pull/22781#discussion_r1932710714 PR Review Comment: https://git.openjdk.org/jdk/pull/22781#discussion_r1932708226