RFR: 8351907: [XWayland] [OL10] Robot.mousePress() is delivered to wrong place [v2]
Alexander Zvegintsev
azvegint at openjdk.org
Mon May 19 23:06:39 UTC 2025
On Fri, 16 May 2025 20:45:39 GMT, Alexander Zvegintsev <azvegint at openjdk.org> wrote:
>> The issue is the inability to move the mouse cursor using `java.awt.Robot` on Oracle Linux 10 (which has not yet been released). FIY, the OL10 is no longer provides an Xorg session, so only Wayland is available.
>> It is a JCK conformance failure.
>>
>> ---
>>
>> In our robot implementation, we emulate mouse/keyboard actions using the XTEST extension protocol.
>>
>> The XTEST calls are now wired to [libEI](https://libinput.pages.freedesktop.org/libei/api/index.html):
>>
>> 1.
>>
>> It now asks for a user confirmation to allow interaction, so we should now be able to click on native applications, window titles, etc.
>>
>> However, our robot implementation is mostly uses XTEST, but there is an exception:
>> for mouse move we use XWarpPointer, which is not part of the XTEST, thus it is not propagated outside of Xwayland server.
>>
>> So we have a situation where mouse is moving only inside Xwayland server, and we see the mouse enter/exit events,
>> on mouse press we call XTestFakeButtonEvent and it is handled by libei,
>> so the click happens where is the actual mouse cursor is in the system. That is why the test fails.
>>
>> To avoid this situation we should use XTestFakeMotionEvent for mouseMove in Xwayland case.
>>
>> It would be a simple solution, but
>>
>>
>> 2.
>>
>> This permission granted by a user doesn't persist across reboots, it timeouts after a period of inactivity.
>>
>> It still seems to conform to the specifications, but we will not be able to conveniently run automated tests in this case.
>>
>> ---
>>
>> So as a solution we can switch the [Remote Desktop XDG portal](https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.RemoteDesktop.html).
>> It has session and `restore_token` functionality to keep permissions granted by a user, similar to what we use in a [Screencast](https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.ScreenCast.html) for taking screenshots.
>> Most of the code can be reused, and it has everything we need.
>>
>>
>> * It is only enabled by default on Wayland and Gnome Shell 47 and higher due to XTEST API complications that first arose in this version. For earlier versions, Screencast is used instead.
>> * A new value has been introduced for the `awt.robot.screenshotMethod` system property - `dbusRemoteDesktop`. It works on Ubuntu 24.04 with Gnome 46, but is not enabled by default.
>> * extra mouse buttons are not supported yet, [JDK-8357142](https://bugs.openjdk.org/browse/JDK-8357142)
>> * Since w...
>
> Alexander Zvegintsev has updated the pull request incrementally with one additional commit since the last revision:
>
> Only call getGnomeShellMajorVersion when the desktop is Gnome.
Phil discovered a hang on Fedora 42, it happens when we call:
1. mouseMove
2. createScreenCapture withing the same remote desktop session
We got the following error if:
- the remote desktop session [initialized without the OpenPipeWireRemote call](https://github.com/azvegint/jdk/blob/5d08133ed00c6f22b71ffe6349591e11ea2813ed/src/java.desktop/unix/native/libawt_xawt/awt/screencast_portal.c#L1131-L1135)
- reusing this session and trying to use pipewire
> startStream:471 screenId#65: stream connecting 0x7f026c84d0f0
onStreamStateChanged:417 screenId#65[loc(0,0) size(1280x832)] state 0 (unconnected) -> 1 (connecting) err (null)
onCoreError:614 !!! pipewire error: id 0, seq: 0, res: -88 (Unknown error -88): connection error
Although it didn't hang on other systems, but it still printed this error in debug mode. It worked because of [the retry](https://github.com/azvegint/jdk/blob/5d08133ed00c6f22b71ffe6349591e11ea2813ed/src/java.desktop/unix/native/libawt_xawt/awt/screencast_pipewire.c#L1034).
Fortunately, it hangs on Fedora 42.
Removing this "optimization" resolves the issue.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/25265#issuecomment-2892471853
More information about the client-libs-dev
mailing list