From bfa7f4ee0dd5988ea54795862a12a1eb1680b3f7 Mon Sep 17 00:00:00 2001 From: emersion Date: Tue, 27 Nov 2018 20:16:55 +0100 Subject: gtk-primary-selection: use impl pattern for sources --- include/wlr/types/wlr_gtk_primary_selection.h | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/wlr/types/wlr_gtk_primary_selection.h b/include/wlr/types/wlr_gtk_primary_selection.h index ed025869..cbf29088 100644 --- a/include/wlr/types/wlr_gtk_primary_selection.h +++ b/include/wlr/types/wlr_gtk_primary_selection.h @@ -45,18 +45,24 @@ struct wlr_gtk_primary_selection_device { 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; - // source implementation - void (*send)(struct wlr_gtk_primary_selection_source *source, - const char *mime_type, int32_t fd); - void (*cancel)(struct wlr_gtk_primary_selection_source *source); - struct { struct wl_signal destroy; } events; @@ -75,8 +81,12 @@ void wlr_gtk_primary_selection_device_manager_set_selection( 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_finish( - 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 -- cgit v1.2.3