gtk-primary-selection: use impl pattern for sources

This commit is contained in:
emersion 2018-11-27 20:16:55 +01:00
parent cbe42d1006
commit bfa7f4ee0d
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
4 changed files with 100 additions and 61 deletions

View file

@ -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