aboutsummaryrefslogtreecommitdiff
path: root/xwayland
diff options
context:
space:
mode:
Diffstat (limited to 'xwayland')
-rw-r--r--xwayland/selection.c46
-rw-r--r--xwayland/xwm.h1
2 files changed, 42 insertions, 5 deletions
diff --git a/xwayland/selection.c b/xwayland/selection.c
index 1c9fcf13..c458f867 100644
--- a/xwayland/selection.c
+++ b/xwayland/selection.c
@@ -1,5 +1,7 @@
#include <xcb/xfixes.h>
+#include <fcntl.h>
#include "wlr/util/log.h"
+#include "wlr/types/wlr_data_device.h"
#include "xwm.h"
static int xwm_handle_selection_property_notify(struct wlr_xwm *xwm,
@@ -30,21 +32,55 @@ static void xwm_handle_selection_request(struct wlr_xwm *xwm,
return;
}
-static void xwm_get_selection_targets(struct wlr_xwm *xwm) {
- wlr_log(L_DEBUG, "TODO: GET SELECTION TARGETS");
-}
-
static void xwm_get_selection_data(struct wlr_xwm *xwm) {
wlr_log(L_DEBUG, "TODO: GET SELECTION DATA");
}
+struct x11_data_source {
+ struct wlr_data_source base;
+ struct wlr_xwm *xwm;
+};
+
+static void data_source_accept(struct wlr_data_source *source, uint32_t time,
+ const char *mime_type) {
+}
+
+static void data_source_send(struct wlr_data_source *base,
+ const char *mime_type, int32_t fd) {
+ struct x11_data_source *source = (struct x11_data_source *)base;
+ struct wlr_xwm *xwm = source->xwm;
+
+ if (strcmp(mime_type, "text/plain;charset=utf-8") == 0) {
+ // Get data for the utf8_string target
+ xcb_convert_selection(xwm->xcb_conn,
+ xwm->selection_window,
+ xwm->atoms[CLIPBOARD],
+ xwm->atoms[UTF8_STRING],
+ xwm->atoms[WL_SELECTION],
+ XCB_TIME_CURRENT_TIME);
+
+ xcb_flush(xwm->xcb_conn);
+
+ fcntl(fd, F_SETFL, O_WRONLY | O_NONBLOCK);
+ xwm->data_source_fd = fd;
+ }
+}
+
+static void data_source_cancel(struct wlr_data_source *source) {
+}
+
+static void xwm_get_selection_targets(struct wlr_xwm *xwm) {
+ // set the wayland clipboard selection to the copied selection
+ wlr_log(L_DEBUG, "TODO: GET SELECTION TARGETS");
+}
+
static void xwm_handle_selection_notify(struct wlr_xwm *xwm,
xcb_generic_event_t *event) {
xcb_selection_notify_event_t *selection_notify =
(xcb_selection_notify_event_t *) event;
if (selection_notify->property == XCB_ATOM_NONE) {
- wlr_log(L_DEBUG, "TODO: convert selection failed");
+ wlr_log(L_ERROR, "convert selection failed");
} else if (selection_notify->target == xwm->atoms[TARGETS]) {
xwm_get_selection_targets(xwm);
} else {
diff --git a/xwayland/xwm.h b/xwayland/xwm.h
index ea1edc65..e1e42a54 100644
--- a/xwayland/xwm.h
+++ b/xwayland/xwm.h
@@ -65,6 +65,7 @@ struct wlr_xwm {
xcb_window_t selection_owner;
xcb_timestamp_t selection_timestamp;
int incr;
+ int data_source_fd;
struct wlr_xwayland_surface *focus_surface;