aboutsummaryrefslogtreecommitdiff
path: root/xwayland
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-12-02 13:16:50 -0500
committerGitHub <noreply@github.com>2018-12-02 13:16:50 -0500
commit8887508fed89d59486a4abcff7a2071326ca8207 (patch)
tree169bfbf09bf0d533da13f4965b896cb1a97dc86b /xwayland
parent3f5f4cec88868818105bdc297f89d51fa378d99d (diff)
parent9f0720c03abcc600b6156b52e367d7cafcf57644 (diff)
Merge pull request #1397 from emersion/refactor-primary-selection
gtk-primary-selection: refactor everything, untie from seat
Diffstat (limited to 'xwayland')
-rw-r--r--xwayland/selection/incoming.c44
-rw-r--r--xwayland/selection/outgoing.c10
-rw-r--r--xwayland/selection/selection.c14
3 files changed, 34 insertions, 34 deletions
diff --git a/xwayland/selection/incoming.c b/xwayland/selection/incoming.c
index d4d7d553..3e97ca04 100644
--- a/xwayland/selection/incoming.c
+++ b/xwayland/selection/incoming.c
@@ -5,11 +5,11 @@
#include <string.h>
#include <unistd.h>
#include <wlr/types/wlr_data_device.h>
-#include <wlr/types/wlr_gtk_primary_selection.h>
+#include <wlr/types/wlr_primary_selection.h>
#include <wlr/util/log.h>
#include <xcb/xfixes.h>
-#include "xwayland/xwm.h"
#include "xwayland/selection.h"
+#include "xwayland/xwm.h"
/**
* Write the X11 selection to a Wayland client.
@@ -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;
@@ -217,22 +217,22 @@ static const struct wlr_data_source_impl data_source_impl = {
};
struct x11_primary_selection_source {
- struct wlr_gtk_primary_selection_source base;
+ struct wlr_primary_selection_source base;
struct wlr_xwm_selection *selection;
struct wl_array mime_types_atoms;
};
-static void primary_selection_source_cancel(
- struct wlr_gtk_primary_selection_source *wlr_source);
+static const struct wlr_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;
+ struct wlr_primary_selection_source *wlr_source) {
+ 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_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(
- struct wlr_gtk_primary_selection_source *wlr_source) {
+static void primary_selection_source_destroy(
+ struct wlr_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_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_primary_selection_source_init(&source->base,
+ &primary_selection_source_impl);
source->selection = selection;
wl_array_init(&source->mime_types_atoms);
@@ -366,10 +370,9 @@ static void xwm_selection_get_targets(struct wlr_xwm_selection *selection) {
bool ok = source_get_targets(selection, &source->base.mime_types,
&source->mime_types_atoms);
if (ok) {
- wlr_seat_set_gtk_primary_selection(xwm->seat, &source->base,
- wl_display_next_serial(xwm->xwayland->wl_display));
+ wlr_seat_set_primary_selection(xwm->seat, &source->base);
} else {
- source->base.cancel(&source->base);
+ wlr_primary_selection_source_destroy(&source->base);
}
} else if (selection == &xwm->dnd_selection) {
// TODO
@@ -424,8 +427,7 @@ int xwm_handle_xfixes_selection_notify(struct wlr_xwm *xwm,
wlr_seat_set_selection(xwm->seat, NULL,
wl_display_next_serial(xwm->xwayland->wl_display));
} else if (selection == &xwm->primary_selection) {
- wlr_seat_set_gtk_primary_selection(xwm->seat, NULL,
- wl_display_next_serial(xwm->xwayland->wl_display));
+ wlr_seat_set_primary_selection(xwm->seat, NULL);
} else if (selection == &xwm->dnd_selection) {
// TODO: DND
} else {
diff --git a/xwayland/selection/outgoing.c b/xwayland/selection/outgoing.c
index b658ab52..fd5021d5 100644
--- a/xwayland/selection/outgoing.c
+++ b/xwayland/selection/outgoing.c
@@ -4,11 +4,11 @@
#include <string.h>
#include <unistd.h>
#include <wlr/types/wlr_data_device.h>
-#include <wlr/types/wlr_gtk_primary_selection.h>
+#include <wlr/types/wlr_primary_selection.h>
#include <wlr/util/log.h>
#include <xcb/xfixes.h>
-#include "xwayland/xwm.h"
#include "xwayland/selection.h"
+#include "xwayland/xwm.h"
static void xwm_selection_send_notify(struct wlr_xwm *xwm,
xcb_selection_request_event_t *req, bool success) {
@@ -195,10 +195,10 @@ static void xwm_selection_source_send(struct wlr_xwm_selection *selection,
return;
}
} else if (selection == &selection->xwm->primary_selection) {
- struct wlr_gtk_primary_selection_source *source =
+ struct wlr_primary_selection_source *source =
selection->xwm->seat->primary_selection_source;
if (source != NULL) {
- source->send(source, mime_type, fd);
+ wlr_primary_selection_source_send(source, mime_type, fd);
return;
}
} else if (selection == &selection->xwm->dnd_selection) {
@@ -231,7 +231,7 @@ static struct wl_array *xwm_selection_source_get_mime_types(
return &source->mime_types;
}
} else if (selection == &selection->xwm->primary_selection) {
- struct wlr_gtk_primary_selection_source *source =
+ struct wlr_primary_selection_source *source =
selection->xwm->seat->primary_selection_source;
if (source != NULL) {
return &source->mime_types;
diff --git a/xwayland/selection/selection.c b/xwayland/selection/selection.c
index a29eeeae..4d7732cb 100644
--- a/xwayland/selection/selection.c
+++ b/xwayland/selection/selection.c
@@ -5,11 +5,11 @@
#include <string.h>
#include <unistd.h>
#include <wlr/types/wlr_data_device.h>
-#include <wlr/types/wlr_gtk_primary_selection.h>
+#include <wlr/types/wlr_primary_selection.h>
#include <wlr/util/log.h>
#include <xcb/xfixes.h>
-#include "xwayland/xwm.h"
#include "xwayland/selection.h"
+#include "xwayland/xwm.h"
void xwm_selection_transfer_remove_source(
struct wlr_xwm_selection_transfer *transfer) {
@@ -231,8 +231,7 @@ void xwm_selection_finish(struct wlr_xwm *xwm) {
if (xwm->seat->primary_selection_source &&
primary_selection_source_is_xwayland(
xwm->seat->primary_selection_source)) {
- wlr_seat_set_gtk_primary_selection(xwm->seat, NULL,
- wl_display_next_serial(xwm->xwayland->wl_display));
+ wlr_seat_set_primary_selection(xwm->seat, NULL);
}
wlr_xwayland_set_seat(xwm->xwayland, NULL);
}
@@ -274,11 +273,10 @@ static void seat_handle_primary_selection(struct wl_listener *listener,
struct wlr_seat *seat = data;
struct wlr_xwm *xwm =
wl_container_of(listener, xwm, seat_primary_selection);
- struct wlr_gtk_primary_selection_source *source = seat->primary_selection_source;
+ struct wlr_primary_selection_source *source =
+ seat->primary_selection_source;
- if (source != NULL &&
- primary_selection_source_is_xwayland(
- source)) {
+ if (source != NULL && primary_selection_source_is_xwayland(source)) {
return;
}