On Tue, 17 Dec 2024 18:48:43 GMT, Phil Race <p...@openjdk.org> wrote:

>> src/java.desktop/share/classes/java/awt/Robot.java line 225:
>> 
>>> 223: //        peer.mouseMove(x, y);
>>> 224:         peer.mouseMove(Math.min(Math.max(x, screenBounds.x), 
>>> screenBounds.x + screenBounds.width),
>>> 225:                 Math.min(Math.max(y, screenBounds.y), screenBounds.y + 
>>> screenBounds.height));
>> 
>> But that will limit current robot's functionality on the multi-monitor 
>> setups. Right now i can move mouse using robot from one screen to another, 
>> With your change it seems to be impossible?
>
> Robot is already created with a screen .. ie GraphicsDevice .. the bounds are 
> from that .. and it is already used elsewhere in Robot
> If that can be across physical screens it will still work.
> If screens are separate then Robot is constrained to that anyway.
> 
> Can you show a specific case where this is a problem ?

I agree with Alex. Currently, it's possible to use a Robot instance to move 
mouse across all the screens in a multi-monitor environment.

According to the specification of [`Robot(GraphicsDevice 
screen)`](https://docs.oracle.com/en/java/javase/23/docs/api/java.desktop/java/awt/Robot.html#%3Cinit%3E(java.awt.GraphicsDevice)),
 <q 
cite="https://docs.oracle.com/en/java/javase/23/docs/api/java.desktop/java/awt/Robot.html#%3Cinit%3E(java.awt.GraphicsDevice)">Coordinates
 passed to `Robot` method calls like `mouseMove`, `getPixelColor` and 
`createScreenCapture` will be interpreted as being in the same coordinate 
system as the specified screen.</q>

I understand this statement correctly, it means that if I create a Robot 
instance with a screen that's not the main one, `Robot.mouse(0, 0)` should move 
the mouse to `(screenBounds.x, screenBounds.y)`.

However, if “share the same coordinate system to form a combined virtual 
screen”, `Robot` is expected to move mouse within the bounds of the virtual 
screen, isn't it?

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

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

Reply via email to