selection: allows using a wrapper source to filter data

1. Added support for intercepting clipboard selection operations.
2. Wraps data sources to control data provision based on client PID.
3. Added wlr_data_receiver to data source's send to identify the
recipient.
4. Includes new example "clipboard-control.c" to illustrate clipboard
permission management.
5. Added PID and client members to data source and receiver for access
control.
This commit is contained in:
JiDe Zhang 2025-09-19 15:58:58 +08:00
parent 1f0fb95e3b
commit 6745b7bd49
18 changed files with 2723 additions and 108 deletions

View file

@ -4,6 +4,7 @@
#include <stdbool.h>
#include <xcb/xfixes.h>
#include <wayland-util.h>
#include <wlr/types/wlr_data_receiver.h>
#define INCR_CHUNK_SIZE (64 * 1024)
@ -34,6 +35,12 @@ struct wlr_xwm_selection_transfer {
int property_start;
xcb_get_property_reply_t *property_reply;
xcb_window_t incoming_window;
// Data receiver reference for Wayland client (may be NULL)
struct wlr_data_receiver *wl_client_receiver;
// Listener for receiver destruction
struct wl_listener receiver_destroy;
};
struct wlr_xwm_selection {
@ -60,7 +67,7 @@ void xwm_selection_transfer_destroy_property_reply(
struct wlr_xwm_selection_transfer *transfer);
void xwm_selection_transfer_init(struct wlr_xwm_selection_transfer *transfer,
struct wlr_xwm_selection *selection);
void xwm_selection_transfer_destroy(
void xwm_selection_transfer_destroy_incoming(
struct wlr_xwm_selection_transfer *transfer);
void xwm_selection_transfer_destroy_outgoing(
@ -88,6 +95,8 @@ bool primary_selection_source_is_xwayland(
void xwm_seat_handle_start_drag(struct wlr_xwm *xwm, struct wlr_drag *drag);
pid_t get_x11_window_pid(xcb_connection_t *conn, xcb_window_t window);
void xwm_selection_init(struct wlr_xwm_selection *selection,
struct wlr_xwm *xwm, xcb_atom_t atom);
void xwm_selection_finish(struct wlr_xwm_selection *selection);