mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-24 06:59:45 -05:00
primary-selection: introduce wlr_primary_selection_source
This is a common interface that can be used for all primary selection protocols, as discussed in [1]. A new function wlr_seat_set_primary_selection is added to set the primary selection for all protocols. The seat now owns again the source, and resets the selection to NULL when destroyed. [1]: https://github.com/swaywm/wlroots/issues/1367#issuecomment-442403454
This commit is contained in:
parent
658b590567
commit
9f0720c03a
15 changed files with 209 additions and 209 deletions
|
|
@ -23,6 +23,7 @@ install_headers(
|
|||
'wlr_output.h',
|
||||
'wlr_pointer.h',
|
||||
'wlr_presentation_time.h',
|
||||
'wlr_primary_selection.h',
|
||||
'wlr_region.h',
|
||||
'wlr_screencopy_v1.h',
|
||||
'wlr_screenshooter.h',
|
||||
|
|
|
|||
|
|
@ -35,37 +35,11 @@ struct wlr_gtk_primary_selection_device {
|
|||
struct wl_list link; // wlr_gtk_primary_selection_device_manager::devices
|
||||
struct wl_list resources; // wl_resource_get_link
|
||||
|
||||
struct wlr_gtk_primary_selection_source *source;
|
||||
struct wl_list offers; // wl_resource_get_link
|
||||
|
||||
struct wl_listener seat_destroy;
|
||||
struct wl_listener seat_focus_change;
|
||||
struct wl_listener source_destroy;
|
||||
|
||||
void *data;
|
||||
};
|
||||
|
||||
/**
|
||||
* A data source implementation. Only the `send` function is mandatory.
|
||||
*/
|
||||
struct wlr_gtk_primary_selection_source_impl {
|
||||
void (*send)(struct wlr_gtk_primary_selection_source *source,
|
||||
const char *mime_type, int fd);
|
||||
void (*destroy)(struct wlr_gtk_primary_selection_source *source);
|
||||
};
|
||||
|
||||
/**
|
||||
* A source is the sending side of a selection.
|
||||
*/
|
||||
struct wlr_gtk_primary_selection_source {
|
||||
const struct wlr_gtk_primary_selection_source_impl *impl;
|
||||
|
||||
// source metadata
|
||||
struct wl_array mime_types;
|
||||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
} events;
|
||||
struct wl_listener seat_primary_selection;
|
||||
|
||||
void *data;
|
||||
};
|
||||
|
|
@ -75,18 +49,4 @@ struct wlr_gtk_primary_selection_device_manager *
|
|||
void wlr_gtk_primary_selection_device_manager_destroy(
|
||||
struct wlr_gtk_primary_selection_device_manager *manager);
|
||||
|
||||
void wlr_gtk_primary_selection_device_manager_set_selection(
|
||||
struct wlr_gtk_primary_selection_device_manager *manager,
|
||||
struct wlr_seat *seat,
|
||||
struct wlr_gtk_primary_selection_source *source);
|
||||
|
||||
void wlr_gtk_primary_selection_source_init(
|
||||
struct wlr_gtk_primary_selection_source *source,
|
||||
const struct wlr_gtk_primary_selection_source_impl *impl);
|
||||
void wlr_gtk_primary_selection_source_destroy(
|
||||
struct wlr_gtk_primary_selection_source *source);
|
||||
void wlr_gtk_primary_selection_source_send(
|
||||
struct wlr_gtk_primary_selection_source *source, const char *mime_type,
|
||||
int fd);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
54
include/wlr/types/wlr_primary_selection.h
Normal file
54
include/wlr/types/wlr_primary_selection.h
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* This an unstable interface of wlroots. No guarantees are made regarding the
|
||||
* future consistency of this API.
|
||||
*/
|
||||
#ifndef WLR_USE_UNSTABLE
|
||||
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
|
||||
#endif
|
||||
|
||||
#ifndef WLR_TYPES_WLR_PRIMARY_SELECTION_H
|
||||
#define WLR_TYPES_WLR_PRIMARY_SELECTION_H
|
||||
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/types/wlr_seat.h>
|
||||
|
||||
struct wlr_primary_selection_source;
|
||||
|
||||
/**
|
||||
* A data source implementation. Only the `send` function is mandatory.
|
||||
*/
|
||||
struct wlr_primary_selection_source_impl {
|
||||
void (*send)(struct wlr_primary_selection_source *source,
|
||||
const char *mime_type, int fd);
|
||||
void (*destroy)(struct wlr_primary_selection_source *source);
|
||||
};
|
||||
|
||||
/**
|
||||
* A source is the sending side of a selection.
|
||||
*/
|
||||
struct wlr_primary_selection_source {
|
||||
const struct wlr_primary_selection_source_impl *impl;
|
||||
|
||||
// source metadata
|
||||
struct wl_array mime_types;
|
||||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
} events;
|
||||
|
||||
void *data;
|
||||
};
|
||||
|
||||
void wlr_primary_selection_source_init(
|
||||
struct wlr_primary_selection_source *source,
|
||||
const struct wlr_primary_selection_source_impl *impl);
|
||||
void wlr_primary_selection_source_destroy(
|
||||
struct wlr_primary_selection_source *source);
|
||||
void wlr_primary_selection_source_send(
|
||||
struct wlr_primary_selection_source *source, const char *mime_type,
|
||||
int fd);
|
||||
|
||||
void wlr_seat_set_primary_selection(struct wlr_seat *seat,
|
||||
struct wlr_primary_selection_source *source);
|
||||
|
||||
#endif
|
||||
|
|
@ -184,6 +184,8 @@ struct wlr_seat_touch_state {
|
|||
struct wlr_seat_touch_grab *default_grab;
|
||||
};
|
||||
|
||||
struct wlr_primary_selection_source;
|
||||
|
||||
struct wlr_seat {
|
||||
struct wl_global *global;
|
||||
struct wl_display *display;
|
||||
|
|
@ -197,8 +199,7 @@ struct wlr_seat {
|
|||
struct wlr_data_source *selection_source;
|
||||
uint32_t selection_serial;
|
||||
|
||||
// not owned by the seat
|
||||
struct wlr_gtk_primary_selection_source *primary_selection_source;
|
||||
struct wlr_primary_selection_source *primary_selection_source;
|
||||
|
||||
// `drag` goes away before `drag_source`, when the implicit grab ends
|
||||
struct wlr_drag *drag;
|
||||
|
|
@ -211,6 +212,7 @@ struct wlr_seat {
|
|||
|
||||
struct wl_listener display_destroy;
|
||||
struct wl_listener selection_source_destroy;
|
||||
struct wl_listener primary_selection_source_destroy;
|
||||
struct wl_listener drag_source_destroy;
|
||||
|
||||
struct {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ struct wlr_xwayland {
|
|||
struct wl_display *wl_display;
|
||||
struct wlr_compositor *compositor;
|
||||
struct wlr_seat *seat;
|
||||
struct wlr_gtk_primary_selection_device_manager *gtk_primary_selection;
|
||||
|
||||
struct {
|
||||
struct wl_signal ready;
|
||||
|
|
@ -226,10 +225,6 @@ void wlr_xwayland_surface_set_fullscreen(struct wlr_xwayland_surface *surface,
|
|||
void wlr_xwayland_set_seat(struct wlr_xwayland *xwayland,
|
||||
struct wlr_seat *seat);
|
||||
|
||||
void wlr_xwayland_set_gtk_primary_selection_device_manager(
|
||||
struct wlr_xwayland *xwayland,
|
||||
struct wlr_gtk_primary_selection_device_manager *manager);
|
||||
|
||||
bool wlr_surface_is_xwayland_surface(struct wlr_surface *surface);
|
||||
|
||||
struct wlr_xwayland_surface *wlr_xwayland_surface_from_wlr_surface(
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#define XDND_VERSION 5
|
||||
|
||||
struct wlr_primary_selection_source;
|
||||
|
||||
struct wlr_xwm_selection;
|
||||
|
||||
struct wlr_xwm_selection_transfer {
|
||||
|
|
@ -62,7 +64,7 @@ int xwm_handle_xfixes_selection_notify(struct wlr_xwm *xwm,
|
|||
xcb_xfixes_selection_notify_event_t *event);
|
||||
bool data_source_is_xwayland(struct wlr_data_source *wlr_source);
|
||||
bool primary_selection_source_is_xwayland(
|
||||
struct wlr_gtk_primary_selection_source *wlr_source);
|
||||
struct wlr_primary_selection_source *wlr_source);
|
||||
|
||||
void xwm_seat_handle_start_drag(struct wlr_xwm *xwm, struct wlr_drag *drag);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue