- Loading...
| Table of Contents |
|---|
| Problem: |
Discussion:
It is doable as of now, but not in a standard and convenient way. It can be done using some shell specific APIs, e.g. org.gnome.Shell.Screenshot DBUS API (which will not work for KDE, it has another API)
It has several drawbacks:
png file, after that you have to read it, decode it.So, it would be great to get some standard API to get screenshot data in memory. I see that there is an open bug against this issue.
Solution: Use xdg-desktop-portal, a cross-platform stable D-Bus API which works on GNOME, KDE and wlroots-based compositors.
Solution #1.
Specifically, it provides org.freedesktop.portal.Screenshot#Screenshot which can be used to create a screenshot.
However, it has some drawbacks(at least on Gnome):
There is also org.freedesktop.portal.Screenshot#PickColor API which can't be used for Robot#getPixelColor needs. It does not allow to take a pixel color at specified location, but interactively asks a user to pick a color with mouse cursor.
Solution #2.
Finally, another possibility is to use the Screencast portal.
This might be a bit of overkill, but it avoids several of the problems mentioned in the screenshot and color picker portals.
Each solution is viable, but #2 seems to be more preferable.
However we may want to implement both of approaches:
If some new display got or disconnected, new permission request from user is required. In case of automated testing it may be a stopper. But we can fallback to a solution #1.
Prototype is available here.
-DuseScreencast=false to switch off screenshot via Screencast. Enabled by default-DscreencastDebug=true to print debug info, disabled by defaultPackages required for permission restoration:
However xdg-desktop-portal-gnome package is installed only for Ubuntu and SLES, OEL9 and RHEL9 does not have it yet.
Where partially means that you can make a screenshot, however it requires user permission on each request.
Problem: The java.awt.Robot class provides methods to emulate input; keyPress(), keyRelease(), mousePress(), mouseRelease()
Discussion:
It mostly works for X11 compatibility mode (except when trying to reach outside XWayland and windows are not restacked on emulated mouse click).
Implementing this via libEI will also fix some of the X11 compatibility issues:
JDK-8280995 X11 compatibility: Robot.mouseMove does not visually move mouse cursor
JDK-8280990 X11 compatibility: XTest emulated mouse click does not bring window to front.
JDK-8280988 X11 compatibility: Click on title to request focus test failures
Solution: This will probably be implemented be libEI. However, its shipping time(even estimated) is not yet known.
You can do most of this using the RemoteDesktop portal. Once permission is given, you can use it to completely control the keyboard and mouse.
Problem: splash screens displays somewhere in top left
Discussion:
This is due to Wayland not allowing windows to position themselves.
This will need a Wayland protocol extension to add a role for an output-only, centered surface.
it'd just need a fallback implementation for compositors that doesn't support it, e.g. a dialog
Add input to this existing issue : https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/67
Implementation will probably be similar to this MR for Picture-In-Picture video: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/132
Solution: None yet (see discussion in the GitLab issue).
Problem: Applications running on XWayland looks blurry on HiDPI screens
Discussion:
Quote from Maxim Kartashev's e-mail:
There's a quality-of-service problem with running via the compatibility layer as under certain circumstances native X windows look blurry. Users with small(ish) HiDPI displays tend to enable fractional scaling and with that enabled (regardless of the actual scale), XWayland pretends that the screen size is smaller and then pixel-stretches the resulting window according to the global scale. This works as a temporary solution, but people get quickly tired of looking at text that is blurry.
See https://gitlab.gnome.org/GNOME/mutter/-/issues/402 and https://github.com/swaywm/sway/issues/5917 for some more details.
Solution: None for XWayland (yet). Wayland-native applications support HiDPI
Problem:
Javadoc for java.awt.Robot#mouseMove says:
/**
* Moves mouse pointer to given screen coordinates.
* @param x X position
* @param y Y position
*/
public synchronized void mouseMove(int x, int y) {
Despite the fact that this mouse movement is successfully emulated within the XWayland server(following mouse press emulation will be in a right place), the mouse cursor does not visually move.
With current specification of java.awt.Robot#mouseMove it may be a conformance issue.
Solution:
Preferred: see earlier point on working with RemoteDesktop portal
Workaround: None
Problem: window does not come to front on emulated mouse click. Window focus transfer happens without issues.
Discussion:
| Code Block | ||||||||
|---|---|---|---|---|---|---|---|---|
| ||||||||
// gcc windowDoesNotComeOnTop.c -o windowDoesNotComeOnTop -lX11 -lXtst && ./windowDoesNotComeOnTop
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <unistd.h>
#include <X11/extensions/XTest.h>
static Display* display;
/*
* We have two windows, one overlapping other.
* Call to XTestFakeButtonEvent on lower window should bring it above the other one, but this doesn't happen on XWayland.
* Real user mouse click works fine.
*/
static void mapNewWindow(Window *win, int x, int y, int width, int height)
{
unsigned long background = WhitePixel(display, DefaultScreen(display));
*win = XCreateSimpleWindow(display, DefaultRootWindow(display), x, y, width, height, 0, 0, background);
XSizeHints hints = {0};
hints.flags = PPosition | PSize;
hints.x = x;
hints.y = y;
hints.width = width;
hints.height = height;
XSetNormalHints(display, *win, &hints);
XSelectInput(display, *win, ButtonPressMask | ButtonReleaseMask | StructureNotifyMask);
XMapWindow(display, *win);
}
void clickOnLeftWindow(Display* display) {
int x = 225;
int y = 150;
printf("XWarpPointer to %d %d\n", x, y);
XWarpPointer(display, None, DefaultRootWindow(display), 0, 0, 0, 0, x, y);
XSync(display, False);
printf("XTestFakeButtonEvent\n");
XTestFakeButtonEvent(display, 1, True, CurrentTime);
XSync(display, False);
XTestFakeButtonEvent(display, 1, False, CurrentTime);
XSync(display, False);
}
int main(void) {
XInitThreads();
display = XOpenDisplay(NULL);
int width = 200;
int height = 100;
Window w1, w2;
mapNewWindow(&w1, 200, 50, width, height);
mapNewWindow(&w2, 350, 50, width, height);
XFlush(display);
int mappedCount = 0;
while (mappedCount < 2) {
XEvent e;
XNextEvent(display, &e);
switch (e.type) {
case MapNotify: {
printf("%lx: MapNotify\n", e.xmap.window);
mappedCount++;
break;
}
default:
printf("%lx: Received event type: %i\n", e.xany.window, e.type);
}
}
sleep(2);
clickOnLeftWindow(display);
while (True) {
XEvent e;
XNextEvent(display, &e);
switch (e.type) {
case ButtonPress:
case ButtonRelease: {
printf("%lx: Button%s\n",
e.xbutton.window,
e.type == ButtonRelease ? "Release" : "Press"
);
break;
}
default:
printf("%lx: type: %i\n", e.xany.window, e.type);
}
}
}
|
| Cannot emulating keyboard/mouse events on Pure Wayland at all, in X11 compatibility mode only inside X11 server | |
| Affected: | Pure Wayland(External), X11 can be used with limitations. |
| Related links: | xdg-desktop-portal/issues/850 |
| Discussion: | The java.awt.Robot class provides methods to emulate input; keyPress(), keyRelease(), mousePress(), mouseRelease() It mostly works for X11 compatibility mode (except when trying to reach outside XWayland and windows are not restacked on emulated mouse click). Implementing this via libEI will also fix some of the X11 compatibility issues: JDK-8280995 X11 compatibility: Robot.mouseMove does not visually move mouse cursor JDK-8280990 X11 compatibility: XTest emulated mouse click does not bring window to front. JDK-8280988 X11 compatibility: Click on title to request focus test failures |
| Solution: | Can be used in X11 compatibility mode with the above-mentioned limitations. Without limitations: This will probably be implemented by libEI. However, its shipping time(even estimated) is not yet known. |
| Workaround: | You can do most of this using the RemoteDesktop portal. Once permission is given, you can use it to completely control the keyboard and mouse. However, you can't keep the permission as you can with |
| Problem: | Unable to control the position of the splash screen (e.g., display it in the center of the screen) |
| Affected: | Pure Wayland(external) |
| Related links: | wayland/wayland-protocols/-/issues/67 |
| Discussion: | The native Wayland splash screen window usually appears somewhere in the upper left corner of the screen. This is due to Wayland not allowing windows to position themselves. This will need a Wayland protocol extension to add a role for an output-only, centered surface. it'd just need a fallback implementation for compositors that doesn't support it, e.g. a dialog Add input to this existing issue : wayland/wayland-protocols/-/issues/67 Implementation will probably be similar to this MR for Picture-In-Picture video: wayland/wayland-protocols/-/merge_requests/132 |
| Solution: | None yet (see discussion in the GitLab issue). |
| Workaround: | use X11 if available |
| Problem: | Applications running on XWayland looks blurry on HiDPI screens |
| Affected: | X11(external) |
| Related links: | xserver/-/issues/1318, GNOME/mutter/-/issues/402 |
| Discussion: | Quote from Maxim Kartashev's e-mail:
|
| Solution: | None |
| Workaround: | None yet |
| Problem: | Robot.mouseMove does not visually move mouse cursor |
| Affected: | X11 |
| Related links: | |
| Discussion: | Javadoc for Despite the fact that this mouse movement is successfully emulated within the XWayland server(following mouse press emulation will be in a right place), the mouse cursor does not visually move. With current specification of |
| Solution: | Preferred: see earlier point on working with RemoteDesktop portal(can't keep the user permission between sessions) |
| Workaround: | Change the documentation to reflect the current behavior |
| Problem: | window does not come to front on emulated mouse click. Window focus transfer happens without issues. | |||||||||||
| Affected: | X11 | |||||||||||
| Related links: | ||||||||||||
| Discussion: |
| |||||||||||
| Solution: | Preferred: emulate mouse click with libei | |||||||||||
| Workaround: | modify tests to use another API to bring window to front (e.g XMapRaised) |
| Problem: | window is not rendered correctly(wrong colors) using setXORMode in Virtual Box with 3D acceleration enabled. |
| Affected: | X11(external) |
| Related links: | xorg/xserver/-/issues/1333 → mesa/mesa/-/issues/6596 |
| Discussion: | |
| Solution: | None, wait for external fix |
| Workaround: |
| Problem: | The java.awt.Robot class provides createScreenCapture() method which currently uses X11-specific APIs |
| Affected: | X11, Pure Wayland |
| Related links: | |
| Discussion: | It is doable as of now, but not in a standard and convenient way. It can be done using some shell specific APIs, e.g. org.gnome.Shell.Screenshot DBUS API (which will not work for KDE, it has another API) It has several drawbacks:
So, it would be great to get some standard API to get screenshot data in memory. I see that there is an open bug against this issue. |
| Solution: | Solution #1. Specifically, it provides org.freedesktop.portal.Screenshot#Screenshot which can be used to create a screenshot. However, it has some drawbacks(at least on Gnome):
There is also org.freedesktop.portal.Screenshot#PickColor API which can't be used for Robot#getPixelColor needs. It does not allow to take a pixel color at specified location, but interactively asks a user to pick a color with mouse cursor. Solution #2. Finally, another possibility is to use the Screencast portal. This might be a bit of overkill, but it avoids several of the problems mentioned in the screenshot and color picker portals.
Each solution is viable, but #2 seems to be more preferable. However we may want to implement both of approaches: If some new display got or disconnected, new permission request from user is required. In case of automated testing it may be a stopper. But we can fallback to a solution #1. Prototype is available here.
|
| Workaround: |
Packages required for permission restoration:
However xdg-desktop-portal-gnome package is installed only for Ubuntu and SLES, OEL9 and RHEL9 does not have it yet.
| works? | xdg-desktop-portal | xdg-desktop-portal-gnome | Gnome | ||
|---|---|---|---|---|---|
| Ubuntu 22.04 | Yes | 1.14.4-1 | 42.1 | 42.2 | |
| OEL9 | Partially | 1.12.1-1 | missing | 40.4.0 | persist_mode and restore_token has no effect |
| RHEL9 | Partially | 1.12.1-1 | missing | 40.4.0 | persist_mode and restore_token has no effect |
| SLES15 | Partially | 1.10.1 | 41.1 | 41.2 | protocol version 3 (1.10 < 1.12), restore_token is not supported |
Where partially means that you can make a screenshot, however it requires user permission on each request.
Preferred: emulate mouse click with libei
Workaround: modify test to use another API to bring window to front(e.g XMapRaised)
Problem: window is not rendered correctly(wrong colors) using setXORMode in Virtual Box with 3D acceleration enabled.
Discussion:
E.g. how should native reproducer be displayed:
And how it actually looks like:
Reported as #1333
Solution: none yet.
| Problem: | We are using XGrabPointer to get mouse input and dismiss popup menus on mouse click. Obviously, it does not work outside of XWayland server. | |||||
| Affected: | X11 | |||||
| Related links: | ||||||
| Discussion: | E.g. if we have shown some popup menu, it will be closed upon clicking on any of XWayland's windows. But it will not be closed if we click on some other window from Wayland.
For a first look this workaround seems to work reliably except only one case: clicking on window's title containing origin component does not lead to focus change, thus we don't hiding a popup.
| |||||
| Solution: |
| Workaround: | Dismiss menu on focus lost event |
| Problem: |
| Some tests are trying to get focus of a window by clicking on its title bar. | |
| Affected: | X11 |
| Related issues: | |
| Discussion: | |
| Solution: |
| use libEI | |
| Workaround: | Click on |
| window's body instead of decorations |
| , request focus in other way |
| Problem: | GUI are crashing if you are trying to map a lot( > ~260) of windows at once. |
| Affected: | X11(external) |
| Related links |
| : |
| xorg/xserver/-/issues/1222. | |
| Discussion: | It may be faced when running some tests which are trying to map a lot of windows, e.g. one for every GraphicsConfiguration. If you have 210 GraphicsConfigurations per display on Xwayland, then running such test in 2 display configuration will lead to crash. |
| Solution: | None (yet) |
| Workaround: | Fix the failing test, e.g. by adding some delay after each ~100 windows displayed |
Can't perform a Drag and Drop operation from X11 client to a Wayland client if there is an intermediate window during the drag.
Reported as #2136
Solution: waiting for a bug fix.
| Problem: | System session crashes when trying to display a huge window |
| Affected: | X11(external) |
| Related links: | xorg/xserver/- |
// gcc hugeFrame.c -o hugeFrame -lX11 && ./hugeFrame #include <X11/Xlib.h> #include <unistd.h> static Display* display; int main(void) { int width = 22000; int height = 25000; display = XOpenDisplay(NULL); Window win = XCreateSimpleWindow(display, DefaultRootWindow(display), 0, 0, width, height, 0, 0L, 0L); XMapWindow(display, win); XFlush(display); sleep(1); }
|
where -2094967296 looks like an integer overflow of 4 * 22000 * 25000 So it fails to create a pool, but doesn't handle it gracefully. | |
| Solution: | external fix released |
| Workaround: |
| Problem: | Drag and drop from java to Wayland apps does not work with current JDK implementation. |
| Affected: | X11(external) |
| Related links: | GNOME/mutter/-/issues/2042, GNOME/mutter/-/merge_requests/2124 |
| Discussion: | |
| Solution: | external fix released |
| Workaround: |
| Problem: | Can't perform a Drag and Drop operation from X11 client to a Wayland client if there is an intermediate window during the drag. |
| Affected: | X11(external) |
| Related links: | GNOME/mutter/-/issues/2136 |
| Discussion: | |
| Solution: | external fix released |
| Workaround: |
where -2094967296 looks like an integer overflow of 4 * 22000 * 25000
So it fails to create a pool, but doesn't handle it gracefully.
Solution: Resolved by 1 and 2. Waiting for its propagation to Linux distros.
Drag and drop from java to wayland apps does not work with current JDK implementation.
Solution: Might be solved by updating to the latest versions of Mutter, see https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2124
JDK-8280992 X11 compatibility| Problem: | Custom cursor(e.g. loaded from GIF) set by Component#setCursor might be displayed in wrong color. |
| Affected: | X11(external) |
| Related links: | /xorg/xserver/-/issues/1303, MR |
| Discussion: | For example on following screenshot X shaped cursor should be displayed in yellow: Reported as /xorg/xserver/-/issues/1303 |
| Solution: |
| external fix released | |
| Workaround: |
| Problem: | We are not getting updates from the system after "changing" screen resolution via XRRSetScreenConfigAndRate. |
| Affected: | X11 (external) |
| Related links: | xorg/xserver/-/merge_requests/731, xorg/xserver/-/issues/1305 |
| Discussion: | Excerpt from Olivier's mail:
This notification would be helpful. This MR adds notification, however it has several issues:
|
Reported as xorg/xserver/-/issues/1305
| Solution: |
| external fix released |
| Workaround: |