aboutsummaryrefslogtreecommitdiff
path: root/xwayland
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-11-28 16:37:35 +0100
committeremersion <contact@emersion.fr>2018-11-29 19:40:28 +0100
commit9f0720c03abcc600b6156b52e367d7cafcf57644 (patch)
tree84c4adf8907e0a2a188edb205b07c72f691acbb9 /xwayland
parent658b5905671ec229e44986e82af2666c40435d43 (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 'xwayland')
-rw-r--r--xwayland/selection/incoming.c31
-rw-r--r--xwayland/selection/outgoing.c10
-rw-r--r--xwayland/selection/selection.c17
-rw-r--r--xwayland/xwayland.c6
4 files changed, 26 insertions, 38 deletions
diff --git a/xwayland/selection/incoming.c b/xwayland/selection/incoming.c
index 3342a761..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.
@@ -217,21 +217,21 @@ 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 const struct wlr_gtk_primary_selection_source_impl
+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) {
+ 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,
+ 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;
@@ -242,14 +242,14 @@ static void primary_selection_source_send(
}
static void primary_selection_source_destroy(
- struct wlr_gtk_primary_selection_source *wlr_source) {
+ struct wlr_primary_selection_source *wlr_source) {
struct x11_primary_selection_source *source =
(struct x11_primary_selection_source *)wlr_source;
wl_array_release(&source->mime_types_atoms);
free(source);
}
-static const struct wlr_gtk_primary_selection_source_impl
+static const struct wlr_primary_selection_source_impl
primary_selection_source_impl = {
.send = primary_selection_source_send,
.destroy = primary_selection_source_destroy,
@@ -361,7 +361,7 @@ static void xwm_selection_get_targets(struct wlr_xwm_selection *selection) {
if (source == NULL) {
return;
}
- wlr_gtk_primary_selection_source_init(&source->base,
+ wlr_primary_selection_source_init(&source->base,
&primary_selection_source_impl);
source->selection = selection;
@@ -369,11 +369,10 @@ 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 && xwm->xwayland->gtk_primary_selection) {
- wlr_gtk_primary_selection_device_manager_set_selection(
- xwm->xwayland->gtk_primary_selection, xwm->seat, &source->base);
+ if (ok) {
+ wlr_seat_set_primary_selection(xwm->seat, &source->base);
} else {
- wlr_gtk_primary_selection_source_destroy(&source->base);
+ wlr_primary_selection_source_destroy(&source->base);
}
} else if (selection == &xwm->dnd_selection) {
// TODO
@@ -427,10 +426,8 @@ int xwm_handle_xfixes_selection_notify(struct wlr_xwm *xwm,
if (selection == &xwm->clipboard_selection) {
wlr_seat_set_selection(xwm->seat, NULL,
wl_display_next_serial(xwm->xwayland->wl_display));
- } else if (selection == &xwm->primary_selection &&
- xwm->xwayland->gtk_primary_selection) {
- wlr_gtk_primary_selection_device_manager_set_selection(
- xwm->xwayland->gtk_primary_selection, xwm->seat, NULL);
+ } else if (selection == &xwm->primary_selection) {
+ 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 1c994e18..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) {
- wlr_gtk_primary_selection_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 db6246bf..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) {
@@ -228,12 +228,10 @@ void xwm_selection_finish(struct wlr_xwm *xwm) {
wlr_seat_set_selection(xwm->seat, NULL,
wl_display_next_serial(xwm->xwayland->wl_display));
}
- if (xwm->xwayland->gtk_primary_selection &&
- xwm->seat->primary_selection_source &&
+ if (xwm->seat->primary_selection_source &&
primary_selection_source_is_xwayland(
xwm->seat->primary_selection_source)) {
- wlr_gtk_primary_selection_device_manager_set_selection(
- xwm->xwayland->gtk_primary_selection, xwm->seat, NULL);
+ wlr_seat_set_primary_selection(xwm->seat, NULL);
}
wlr_xwayland_set_seat(xwm->xwayland, NULL);
}
@@ -275,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;
}
diff --git a/xwayland/xwayland.c b/xwayland/xwayland.c
index bbdee1a7..e6d3502c 100644
--- a/xwayland/xwayland.c
+++ b/xwayland/xwayland.c
@@ -505,9 +505,3 @@ void wlr_xwayland_set_seat(struct wlr_xwayland *xwayland,
xwayland->seat_destroy.notify = xwayland_handle_seat_destroy;
wl_signal_add(&seat->events.destroy, &xwayland->seat_destroy);
}
-
-void wlr_xwayland_set_gtk_primary_selection_device_manager(
- struct wlr_xwayland *xwayland,
- struct wlr_gtk_primary_selection_device_manager *manager) {
- xwayland->gtk_primary_selection = manager;
-}