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

Phil Race prr at openjdk.org
Fri Dec 20 20:40:35 UTC 2024


On Fri, 20 Dec 2024 20:22:20 GMT, Harshitha Onkar <honkar at openjdk.org> wrote:

>> For me, the test *without the fix* prints
>> 
>> Current mouse location: java.awt.Point[x=0,y=200]
>> 
>> The mouse cursor moves to 200, 200 and then to 0, 200 on the screen.
>
> Displays: 2 
> Placement: Side-by-side, with the bottom edge aligned as below
> 
> <img width="478" alt="image" src="https://github.com/user-attachments/assets/7ea5be69-989f-42b5-ac26-631d170d8db0" />
> 
> Screen bounds:
> Win32GraphicsDevice[screen=0]:java.awt.Rectangle[x=-1920,y=363,width=1280,height=720]
> Win32GraphicsDevice[screen=1]:java.awt.Rectangle[x=0,y=0,width=2293,height=960]
> 
> Stack Trace:
> ----------System.err:(11/959)----------
> java.lang.NullPointerException: Cannot invoke "java.awt.PointerInfo.getLocation()" because the return value of "java.awt.MouseInfo.getPointerInfo()" is null
> 	at MouseMoveOffScreen.main(MouseMoveOffScreen.java:57)
> 	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
> 	at java.base/java.lang.reflect.Method.invoke(Method.java:565)
> 	at com.sun.javatest.regtest.agent.MainWrapper$MainTask.run(MainWrapper.java:138)
> 	at java.base/java.lang.Thread.run(Thread.java:1447)
> 
> JavaTest Message: Test threw exception: java.lang.NullPointerException: Cannot invoke "java.awt.PointerInfo.getLocation()" because the return value of "java.awt.MouseInfo.getPointerInfo()" is null
> JavaTest Message: shutting down test

> For me, the test _without the fix_ prints
> 
> ```
> Current mouse location: java.awt.Point[x=0,y=200]
> ```
> 
> The mouse cursor moves to 200, 200 and then to 0, 200 on the screen.


What platform ? Alisen did say in the description that Windows & Linux clamp which presumably is either something elsewhere in the JDK implementation, or just how the platform works. I looked (briefly) at Linux and we just pass the values to XWarpPointer so I assumed it was the platform ..

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22781#discussion_r1894371103


More information about the client-libs-dev mailing list