summaryrefslogtreecommitdiff
path: root/src/platform/wayland/keyboard.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/platform/wayland/keyboard.c')
-rw-r--r--src/platform/wayland/keyboard.c54
1 files changed, 46 insertions, 8 deletions
diff --git a/src/platform/wayland/keyboard.c b/src/platform/wayland/keyboard.c
index 038ba78..7f8274d 100644
--- a/src/platform/wayland/keyboard.c
+++ b/src/platform/wayland/keyboard.c
@@ -1,7 +1,7 @@
#include "internal.h"
+#include <errno.h>
#include "common/keyboard.h"
#include "keymap.h"
-#include <errno.h>
#define XKB_EVDEV_OFFSET 8
#define KEYMAP_MAX_BYTES (8u * 1024 * 1024)
@@ -427,27 +427,65 @@ int wayland_display_modifiers(const struct wayland_display *c)
void wayland_display_copy(struct wayland_display *c, enum yasl_selection sel, const char *text)
{
+ (void)wayland_display_copy_text(c, sel, text);
+}
+
+bool wayland_display_copy_text(struct wayland_display *c, enum yasl_selection sel,
+ const char *text)
+{
struct seat *s = c ? (c->active_seat ? c->active_seat : c->seats) : NULL;
- if (!s || !s->clipboard)
- return;
- if (sel == YASL_PRIMARY)
- clipboard_copy_primary(s->clipboard, text, s->input_serial);
- else
+ if (!text) {
+ errno = EINVAL;
+ return false;
+ }
+ if (!s || !s->clipboard) {
+ errno = ENOTSUP;
+ return false;
+ }
+ if (!s->input_serial) {
+ errno = EAGAIN;
+ return false;
+ }
+ errno = 0;
+ bool ok = sel == YASL_PRIMARY ?
+ clipboard_copy_primary(s->clipboard, text, s->input_serial) :
clipboard_copy(s->clipboard, text, s->input_serial);
+ return ok;
}
void wayland_display_paste(struct wayland_display *c, enum yasl_selection sel, struct wayland_surface *target)
{
struct seat *s = c ? (c->active_seat ? c->active_seat : c->seats) : NULL;
- if (!s || !s->clipboard)
+ if (!target || target->closed || target->destroyed) return;
+ if (!s || !s->clipboard) {
+ yasl_surface_complete_paste(&target->base, 0,
+ YASL_TRANSFER_UNAVAILABLE, NULL, 0);
return;
- if (!target || target->closed) return;
+ }
if (sel == YASL_PRIMARY)
clipboard_paste_primary(s->clipboard, target->surface);
else
clipboard_paste(s->clipboard, target->surface);
}
+bool wayland_display_request_paste(struct wayland_display *c, enum yasl_selection sel,
+ struct wayland_surface *target, uint64_t request_id)
+{
+ struct seat *s = c ? (c->active_seat ? c->active_seat : c->seats) : NULL;
+ if (!target || target->closed || target->destroyed || !request_id) {
+ errno = EINVAL;
+ return false;
+ }
+ if (!s || !s->clipboard) {
+ errno = ENOTSUP;
+ return false;
+ }
+ errno = 0;
+ bool ok = clipboard_request_paste(s->clipboard, sel, target->surface, request_id);
+ if (!ok) errno = ENOMEM;
+ return ok;
+}
+
bool wayland_surface_poll_event(struct wayland_surface *w, struct yasl_event *ev)
{
return w && ev && input_queue_pop(&w->input, ev);