<AWT Dev> [10] JDK-8190326: Robot.mouseMove uses scaling factor of main display on unscaled second display

Sergey Bylokhov Sergey.Bylokhov at oracle.com
Tue Nov 7 18:37:04 UTC 2017

On 07/11/2017 10:18, shashidhara veerabhadraiah wrote:
> Hi Sergey, The problem is with using the wrong scaling for the cursor position. To explain:
> 	Primary Monitor res: 1920 * 1080 with scaling factor: 1.25 and a secondary monitor with res: 1600 * 1200 with scaling factor: 1.00.
> When we pass a mouseMove(1921, 500) we would apply a scaling factor of 1.25 and calculate the device coordinates and send the mouse event. Currently this is the behaviour.
> Actually we should be applying the secondary monitor’s scaling factor of 1.00(as this position is outside the primary monitor’s range) and then calculate the device coordinates and send the mouse event to move there. As you can see the diff in the awn_Robot.cpp(Only line nos. 83-87), previously we always used to use the primaryIndex(primary monitor) scaling factor. Now the scaling factor is updated to use the intended cursor move’s position of the respective monitor. So I do not think we can handle this by changing in the Java code than in the native code as the issue is with native code of the use of the wrong scaling factor.

If I am not missing something, this is how WWindowPeer.setBounds() is 
implemented? It finds the target GConfig and then does some math. Its a 
generic algorithm for moving windows/cursors or taking a screenshot.

The Robot.createCompatibleImage()/WWindowPeer.setBounds() already use 
this code:
gc = SwingUtilities2.getGraphicsConfigurationAtPoint()

Best regards, Sergey.

More information about the awt-dev mailing list