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 <ofourdan@redhat.com>
Reviewed-by: Joshua Ashton <joshua@froggi.es>
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
This commit is contained in:
Olivier Fourdan 2023-09-29 10:19:13 +02:00 committed by Olivier Fourdan
parent 287638db59
commit cfcbb075c2
6 changed files with 29 additions and 2 deletions

View File

@ -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.

View File

@ -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',
]

View File

@ -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
}
}

View File

@ -67,6 +67,7 @@ struct xwl_screen {
int host_grab;
int has_grab;
int decorate;
int enable_ei_portal;
CreateScreenResourcesProcPtr CreateScreenResources;
CloseScreenProcPtr CloseScreen;

View File

@ -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);

View File

@ -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;
}