diff options
author | emersion <contact@emersion.fr> | 2018-11-28 16:37:35 +0100 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2018-11-29 19:40:28 +0100 |
commit | 9f0720c03abcc600b6156b52e367d7cafcf57644 (patch) | |
tree | 84c4adf8907e0a2a188edb205b07c72f691acbb9 /include/wlr | |
parent | 658b5905671ec229e44986e82af2666c40435d43 (diff) |
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
Diffstat (limited to 'include/wlr')
-rw-r--r-- | include/wlr/types/meson.build | 1 | ||||
-rw-r--r-- | include/wlr/types/wlr_gtk_primary_selection.h | 42 | ||||
-rw-r--r-- | include/wlr/types/wlr_primary_selection.h | 54 | ||||
-rw-r--r-- | include/wlr/types/wlr_seat.h | 6 | ||||
-rw-r--r-- | include/wlr/xwayland.h | 5 |
5 files changed, 60 insertions, 48 deletions
diff --git a/include/wlr/types/meson.build b/include/wlr/types/meson.build index df611970..491d4a50 100644 --- a/include/wlr/types/meson.build +++ b/include/wlr/types/meson.build @@ -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', diff --git a/include/wlr/types/wlr_gtk_primary_selection.h b/include/wlr/types/wlr_gtk_primary_selection.h index cbf29088..7cf34201 100644 --- a/include/wlr/types/wlr_gtk_primary_selection.h +++ b/include/wlr/types/wlr_gtk_primary_selection.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 diff --git a/include/wlr/types/wlr_primary_selection.h b/include/wlr/types/wlr_primary_selection.h new file mode 100644 index 00000000..9be61acc --- /dev/null +++ b/include/wlr/types/wlr_primary_selection.h @@ -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 diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index 0b8f15ab..942a3420 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -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 { diff --git a/include/wlr/xwayland.h b/include/wlr/xwayland.h index 9a7f0f07..40cc8848 100644 --- a/include/wlr/xwayland.h +++ b/include/wlr/xwayland.h @@ -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( |