xwayland: Implement clipboard and primary selection

So that it is possible to copy and paste between Xwayland rootful and
other Wayland or even X11 clients outside of Xwayland rootful.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1873
Assisted-by: Cursor AI
This commit is contained in:
Olivier Fourdan 2026-03-09 16:52:18 +01:00
parent d0f41bbf35
commit 40e8d8e52b
6 changed files with 1203 additions and 0 deletions

View file

@ -2,6 +2,8 @@ srcs = [
'xwayland.c',
'xwayland-input.c',
'xwayland-input.h',
'xwayland-selection.c',
'xwayland-selection.h',
'xwayland-cursor.c',
'xwayland-cursor.h',
'xwayland-drm-lease.h',

View file

@ -42,6 +42,7 @@
#include "xwayland-cursor.h"
#include "xwayland-input.h"
#include "xwayland-selection.h"
#include "xwayland-window.h"
#include "xwayland-screen.h"
@ -634,6 +635,8 @@ pointer_handle_leave(void *data, struct wl_pointer *pointer,
if (xwl_screen->rootless)
xwl_seat_leave_ptr(xwl_seat, focus_lost);
else
xwl_selection_offer_after_pointer_leave(xwl_seat);
}
static void
@ -1994,6 +1997,8 @@ create_input_device(struct xwl_screen *xwl_screen, uint32_t id, uint32_t version
xorg_list_init(&xwl_seat->touches);
xorg_list_init(&xwl_seat->sync_pending);
xwl_selection_init(xwl_seat);
}
void
@ -2002,6 +2007,8 @@ xwl_seat_destroy(struct xwl_seat *xwl_seat)
struct xwl_touch *xwl_touch, *next_xwl_touch;
struct sync_pending *p, *npd;
xwl_selection_fini(xwl_seat);
xorg_list_for_each_entry_safe(xwl_touch, next_xwl_touch,
&xwl_seat->touches, link_touch) {
xorg_list_del(&xwl_touch->link_touch);

View file

@ -56,6 +56,7 @@
#include "xwayland-pixmap.h"
#include "xwayland-present.h"
#include "xwayland-shm.h"
#include "xwayland-selection.h"
#ifdef XWL_HAS_EI
#include "xwayland-xtest.h"
#endif

View file

@ -39,6 +39,7 @@
#include "xwayland-glamor.h"
#include "xwayland-drm-lease.h"
#include "xwayland-dmabuf.h"
#include "xwayland-selection.h"
#ifdef XWL_HAS_LIBDECOR
#include <libdecor.h>
@ -121,6 +122,7 @@ struct xwl_screen {
struct xdg_system_bell_v1 *system_bell;
struct wl_data_device_manager *data_device_manager;
struct zwp_primary_selection_device_manager_v1 *primary_selection_manager;
struct xwl_selection *selection_bridge;
struct xorg_list drm_lease_devices;
struct xorg_list queued_drm_lease_devices;
struct xorg_list drm_leases;

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,26 @@
/*
* Copyright © 2026 Red Hat.
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies
* and that both that copyright notice and this permission notice
* appear in supporting documentation, and that the name of the
* copyright holders not be used in advertising or publicity
* pertaining to distribution of the software without specific,
* written prior permission. The copyright holders make no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied
* warranty.
*/
#ifndef XWAYLAND_SELECTION_H
#define XWAYLAND_SELECTION_H
#include "xwayland-types.h"
void xwl_selection_init(struct xwl_seat *xwl_seat);
void xwl_selection_fini(struct xwl_seat *xwl_seat);
void xwl_selection_offer_after_pointer_leave(struct xwl_seat *xwl_seat);
#endif /* XWAYLAND_SELECTION_H */