RFR: 8345538: Robot.mouseMove doesn't clamp bounds on macOS when trying to move mouse off screen [v6]
Alisen Chung
achung at openjdk.org
Mon Feb 3 22:58:17 UTC 2025
On Fri, 31 Jan 2025 19:51:07 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
> In macOS? Do you mean in macOS-specific code in JDK?
>
> ~If the code to clamp mouse coordinates has already been written, why are you writing new code instead of re-using the existing code?~
Yes, I meant macOS-specific code in JDK. The idea was I'm moving the macOS-specific code into shared code since I think clamping should be part of mouseMove behavior.
> > But why this coordinates nonexistent, you at least can move undecorated windows there, that coordinates just is not visible on teh screen.
>
> This is the question we have to answer first: Are the coordinates off the virtual screen invalid, non-existent?
> Then, when you use a physical mouse, the OS doesn't allow moving the mouse cursor outside of the virtual screen bounds. Does this imply Java should prevent moving the mouse cursor off the virtual screen, too?
I do think that robot should emulate what you can manually do with a mouse/keyboard, and since we can't interact with a window offscreen normally robot shouldn't be able to do so either. Also, since mousePress and mouseRelease can't be done offscreen either because of the checkMousePos() call anyway, it doesn't make sense to keep mouseMove behavior as is as the only mouse function to be able to go offscreen.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/22781#issuecomment-2632364505
More information about the client-libs-dev
mailing list