aboutsummaryrefslogtreecommitdiff
path: root/xwayland
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-11-27 20:16:55 +0100
committeremersion <contact@emersion.fr>2018-11-27 20:16:55 +0100
commitbfa7f4ee0dd5988ea54795862a12a1eb1680b3f7 (patch)
treea9ae2aa231eebf9cbb49afa70503d8277cbd700d /xwayland
parentcbe42d100644307af92f71a04b68a005c31c62d6 (diff)
gtk-primary-selection: use impl pattern for sources
Diffstat (limited to 'xwayland')
-rw-r--r--xwayland/selection/incoming.c28
-rw-r--r--xwayland/selection/outgoing.c2
2 files changed, 17 insertions, 13 deletions
diff --git a/xwayland/selection/incoming.c b/xwayland/selection/incoming.c
index 0fe759a0..3342a761 100644
--- a/xwayland/selection/incoming.c
+++ b/xwayland/selection/incoming.c
@@ -137,7 +137,7 @@ static void xwm_selection_get_data(struct wlr_xwm_selection *selection) {
static void source_send(struct wlr_xwm_selection *selection,
struct wl_array *mime_types, struct wl_array *mime_types_atoms,
- const char *requested_mime_type, int32_t fd) {
+ const char *requested_mime_type, int fd) {
struct wlr_xwm *xwm = selection->xwm;
struct wlr_xwm_selection_transfer *transfer = &selection->incoming;
@@ -222,17 +222,17 @@ struct x11_primary_selection_source {
struct wl_array mime_types_atoms;
};
-static void primary_selection_source_cancel(
- struct wlr_gtk_primary_selection_source *wlr_source);
+static const struct wlr_gtk_primary_selection_source_impl
+ primary_selection_source_impl;
bool primary_selection_source_is_xwayland(
struct wlr_gtk_primary_selection_source *wlr_source) {
- return wlr_source->cancel == primary_selection_source_cancel;
+ return wlr_source->impl == &primary_selection_source_impl;
}
static void primary_selection_source_send(
- struct wlr_gtk_primary_selection_source *wlr_source, const char *mime_type,
- int32_t fd) {
+ struct wlr_gtk_primary_selection_source *wlr_source,
+ const char *mime_type, int fd) {
struct x11_primary_selection_source *source =
(struct x11_primary_selection_source *)wlr_source;
struct wlr_xwm_selection *selection = source->selection;
@@ -241,15 +241,20 @@ static void primary_selection_source_send(
mime_type, fd);
}
-static void primary_selection_source_cancel(
+static void primary_selection_source_destroy(
struct wlr_gtk_primary_selection_source *wlr_source) {
struct x11_primary_selection_source *source =
(struct x11_primary_selection_source *)wlr_source;
- wlr_gtk_primary_selection_source_finish(&source->base);
wl_array_release(&source->mime_types_atoms);
free(source);
}
+static const struct wlr_gtk_primary_selection_source_impl
+ primary_selection_source_impl = {
+ .send = primary_selection_source_send,
+ .destroy = primary_selection_source_destroy,
+};
+
static bool source_get_targets(struct wlr_xwm_selection *selection,
struct wl_array *mime_types, struct wl_array *mime_types_atoms) {
struct wlr_xwm *xwm = selection->xwm;
@@ -356,9 +361,8 @@ static void xwm_selection_get_targets(struct wlr_xwm_selection *selection) {
if (source == NULL) {
return;
}
- wlr_gtk_primary_selection_source_init(&source->base);
- source->base.send = primary_selection_source_send;
- source->base.cancel = primary_selection_source_cancel;
+ wlr_gtk_primary_selection_source_init(&source->base,
+ &primary_selection_source_impl);
source->selection = selection;
wl_array_init(&source->mime_types_atoms);
@@ -369,7 +373,7 @@ static void xwm_selection_get_targets(struct wlr_xwm_selection *selection) {
wlr_gtk_primary_selection_device_manager_set_selection(
xwm->xwayland->gtk_primary_selection, xwm->seat, &source->base);
} else {
- source->base.cancel(&source->base);
+ wlr_gtk_primary_selection_source_destroy(&source->base);
}
} else if (selection == &xwm->dnd_selection) {
// TODO
diff --git a/xwayland/selection/outgoing.c b/xwayland/selection/outgoing.c
index b658ab52..1c994e18 100644
--- a/xwayland/selection/outgoing.c
+++ b/xwayland/selection/outgoing.c
@@ -198,7 +198,7 @@ static void xwm_selection_source_send(struct wlr_xwm_selection *selection,
struct wlr_gtk_primary_selection_source *source =
selection->xwm->seat->primary_selection_source;
if (source != NULL) {
- source->send(source, mime_type, fd);
+ wlr_gtk_primary_selection_source_send(source, mime_type, fd);
return;
}
} else if (selection == &selection->xwm->dnd_selection) {