summaryrefslogtreecommitdiff
path: root/src/common/input.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/input.c')
-rw-r--r--src/common/input.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/common/input.c b/src/common/input.c
index ce3219c..511cd0a 100644
--- a/src/common/input.c
+++ b/src/common/input.c
@@ -24,14 +24,15 @@ bool input_queue_push(struct input_queue *q, const struct yasl_event *ev)
struct yasl_event copy = *ev;
char *owned = NULL;
if (!copy.time_ns) copy.time_ns = yasl_loop_now_ns();
- if (has_text(ev)) {
+ if (has_text(ev) && !q->publish) {
size_t len = ev->text.len;
if ((!ev->text.data && len) || len == SIZE_MAX) goto failed;
owned = malloc(len + 1);
if (!owned) goto failed;
if (len) memcpy(owned, ev->text.data, len);
owned[len] = '\0';
- copy.text.data = owned;
+ if (ev->type == YASL_EVENT_PASTE) copy.paste.data = owned;
+ else copy.text.data = owned;
}
uint32_t buttons = q->buttons;
switch (ev->type) {
@@ -67,6 +68,10 @@ bool input_queue_push(struct input_queue *q, const struct yasl_event *ev)
}
if (ev->type >= YASL_EVENT_POINTER_DOWN && ev->type <= YASL_EVENT_POINTER_LEAVE)
copy.pointer.buttons = buttons;
+ if (q->publish) {
+ q->buttons = buttons;
+ return q->publish(&copy, q->publish_ud);
+ }
if (q->count == q->capacity) {
size_t capacity = q->capacity ? q->capacity * 2 : 32;
if (capacity < q->capacity || capacity > SIZE_MAX / sizeof(*q->events))
@@ -127,8 +132,12 @@ bool input_queue_pop(struct input_queue *q, struct yasl_event *ev)
void input_queue_clear(struct input_queue *q)
{
+ bool (*publish)(const struct yasl_event *, void *) = q->publish;
+ void *publish_ud = q->publish_ud;
discard_pending(q);
free(q->last_text);
free(q->events);
*q = (struct input_queue){0};
+ q->publish = publish;
+ q->publish_ud = publish_ud;
}