From cfcbb075c23fc668e84a381c9c2c165a95798cf4 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Fri, 29 Sep 2023 10:19:13 +0200 Subject: [PATCH] xwayland: Add an option to enable EI portal support With EI support wired to XTEST, and oeffis being enabled unconditionally means that Xwayland will always go through the XDG portal for XTEST when supported. While this the intended behavior for the general use case of Xwayland running rootless on a desktop compositor, that breaks when Xwayland is running on a nested compositor, because the portal is for the entire session and not limited to the nested Wayland compositor. Xwayland itself, as a regular Wayland client, has no way to tell that it is running on a nested compositor. So to keep backward compatibility with existing (and also common) use cases such as nested compositors, best is to disable support for the XDG portal by default, and add a new command line option "-enable-ei-portal" for the Wayland compositors (who spawn Xwayland rootless) to explicitly enable support for the input emulation XDG portal in Xwayland. A Wayland compositor running nested should not use that command line option with Xwayland. Signed-off-by: Olivier Fourdan Reviewed-by: Joshua Ashton Fixes: a1333342 - xwayland: Add XTEST support using EIS Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1586 See-also: https://gitlab.gnome.org/GNOME/mutter/-/issues/3047 --- hw/xwayland/man/Xwayland.man | 9 +++++++++ hw/xwayland/meson.build | 1 + hw/xwayland/xwayland-screen.c | 7 +++++++ hw/xwayland/xwayland-screen.h | 1 + hw/xwayland/xwayland-xtest.c | 7 +++++-- hw/xwayland/xwayland.c | 6 ++++++ 6 files changed, 29 insertions(+), 2 deletions(-) diff --git a/hw/xwayland/man/Xwayland.man b/hw/xwayland/man/Xwayland.man index 02b333be9..9ecb65001 100644 --- a/hw/xwayland/man/Xwayland.man +++ b/hw/xwayland/man/Xwayland.man @@ -61,6 +61,15 @@ backend first, then fallback to the GBM backend if EGLStream is not supported by the Wayland server. Without this option, \fIXwayland\fP tries the GBM backend first, and fallback to EGLStream if GBM is not usable. .TP 8 +.B \-enable-ei-portal +Enable support for the XDG portal for input emulation. + +A Wayland compositor running nested should not use that command line +option with Xwayland. + +This option has no effect if the compositor doesn't support the relevant +XDG portal or if Xwayland was not compiled with EI and OEFFIS support. +.TP 8 .B \-fullscreen Set the Xwayland window fullscreen when running rootful. diff --git a/hw/xwayland/meson.build b/hw/xwayland/meson.build index f2038ab7c..54529b64e 100644 --- a/hw/xwayland/meson.build +++ b/hw/xwayland/meson.build @@ -186,6 +186,7 @@ xwayland_vars = [ 'have_fullscreen=true', 'have_host_grab=true', 'have_decorate=' + have_libdecor.to_string(), + 'have_enable_ei_portal=' + build_ei_portal.to_string(), 'have_byteswappedclients=true', ] diff --git a/hw/xwayland/xwayland-screen.c b/hw/xwayland/xwayland-screen.c index c00f976a8..cc14e0771 100644 --- a/hw/xwayland/xwayland-screen.c +++ b/hw/xwayland/xwayland-screen.c @@ -812,6 +812,13 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv) use_fixed_size = 1; #else ErrorF("This build does not have libdecor support\n"); +#endif + } + else if (strcmp(argv[i], "-enable-ei-portal") == 0) { +#ifdef XWL_HAS_EI_PORTAL + xwl_screen->enable_ei_portal = 1; +#else + ErrorF("This build does not have XDG portal support\n"); #endif } } diff --git a/hw/xwayland/xwayland-screen.h b/hw/xwayland/xwayland-screen.h index 94033aabf..bd66dd681 100644 --- a/hw/xwayland/xwayland-screen.h +++ b/hw/xwayland/xwayland-screen.h @@ -67,6 +67,7 @@ struct xwl_screen { int host_grab; int has_grab; int decorate; + int enable_ei_portal; CreateScreenResourcesProcPtr CreateScreenResources; CloseScreenProcPtr CloseScreen; diff --git a/hw/xwayland/xwayland-xtest.c b/hw/xwayland/xwayland-xtest.c index 333013cea..74778ce8b 100644 --- a/hw/xwayland/xwayland-xtest.c +++ b/hw/xwayland/xwayland-xtest.c @@ -334,12 +334,14 @@ setup_ei_from_socket(struct xwl_ei_client *xwl_ei_client) static struct xwl_ei_client * setup_ei(ClientPtr client) { + ScreenPtr pScreen = screenInfo.screens[0]; struct xwl_ei_client *xwl_ei_client = NULL; + struct xwl_screen *xwl_screen = xwl_screen_get(pScreen); struct ei *ei = NULL; char buffer[PATH_MAX]; const char *cmdname; char *client_name = NULL; - bool status; + bool status = false; cmdname = GetClientCmdName(client); if (cmdname) { @@ -375,7 +377,8 @@ setup_ei(ClientPtr client) xorg_list_init(&xwl_ei_client->pending_emulated_events); xorg_list_init(&xwl_ei_client->abs_devices); - status = setup_oeffis(xwl_ei_client); + if (xwl_screen->enable_ei_portal) + status = setup_oeffis(xwl_ei_client); if (!status) status = setup_ei_from_socket(xwl_ei_client); diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c index 672dc3168..3f9c5c269 100644 --- a/hw/xwayland/xwayland.c +++ b/hw/xwayland/xwayland.c @@ -109,6 +109,9 @@ ddxUseMsg(void) #ifdef XWL_HAS_LIBDECOR ErrorF("-decorate add decorations to Xwayland when rootful\n"); #endif +#ifdef XWL_HAS_EI_PORTAL + ErrorF("-enable-ei-portal use the XDG portal for input emulation\n"); +#endif } static int init_fd = -1; @@ -246,6 +249,9 @@ ddxProcessArgument(int argc, char *argv[], int i) else if (strcmp(argv[i], "-decorate") == 0) { return 1; } + else if (strcmp(argv[i], "-enable-ei-portal") == 0) { + return 1; + } return 0; }