xwayland: Add a new command line option to enable selection bridge

Add a new commmand line option to enable the Xwayland
clipboard selection bridge when running in rootful mode.

By default, clipboard selection bridge is disabled to keep the default
of having Xwayland rootful running isolated from the rest of the
applications.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
This commit is contained in:
Olivier Fourdan 2026-03-10 09:57:04 +01:00
parent 40e8d8e52b
commit fcf42617d4
5 changed files with 23 additions and 0 deletions

View file

@ -65,6 +65,13 @@ 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 \-enable-clipboard
Enable the Xwayland clipboard selection bridge in rootful mode, syncing
the X11 CLIPBOARD and PRIMARY selections with the Wayland clipboard and
primary selection.
This option is not compatible with rootless mode (\fI-rootless\fP).
.TP 8
.B \-fullscreen
Set the Xwayland window fullscreen when running rootful.

View file

@ -992,6 +992,9 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
ErrorF("This build does not have XDG portal support\n");
#endif
}
else if (strcmp(argv[i], "-enable-clipboard") == 0) {
xwl_screen->enable_clipboard = 1;
}
else if (strcmp(argv[i], "-nokeymap") == 0) {
xwl_screen->nokeymap = 1;
}
@ -1077,6 +1080,11 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
return FALSE;
}
if (xwl_screen->rootless && xwl_screen->enable_clipboard) {
ErrorF("error, cannot use the clipboard selection bridge when running rootless\n");
return FALSE;
}
if (!xwl_screen->rootless && !xwl_screen->xdg_wm_base) {
ErrorF("missing XDG-WM-Base protocol\n");
return FALSE;

View file

@ -66,6 +66,7 @@ struct xwl_screen {
int has_grab;
int decorate;
int enable_ei_portal;
int enable_clipboard;
int nokeymap;
int hidpi;

View file

@ -1111,6 +1111,9 @@ xwl_selection_init(struct xwl_seat *xwl_seat)
if (xwl_screen->rootless)
return;
if (!xwl_screen->enable_clipboard)
return;
if (xwl_screen->selection_bridge)
return;

View file

@ -119,6 +119,7 @@ ddxUseMsg(void)
#ifdef XWL_HAS_EI_PORTAL
ErrorF("-enable-ei-portal use the XDG portal for input emulation\n");
#endif
ErrorF("-enable-clipboard enable Xwayland clipboard selection bridge\n");
}
static int init_fd = -1;
@ -247,6 +248,9 @@ ddxProcessArgument(int argc, char *argv[], int i)
else if (strcmp(argv[i], "-enable-ei-portal") == 0) {
return 1;
}
else if (strcmp(argv[i], "-enable-clipboard") == 0) {
return 1;
}
else if (strcmp(argv[i], "-output") == 0) {
CHECK_FOR_REQUIRED_ARGUMENTS(1);
return 2;