diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 21:23:03 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 21:23:03 +0300 |
| commit | dd1775a9927922c14f8679ccbc4d3ca8d5917e20 (patch) | |
| tree | 3acc442bb4a3470364b74aa82ff67cb84d555c45 /src/common/input.c | |
| parent | ecb81aeea4c0c880b3a60a0dc8418c4bf2a7cf85 (diff) | |
public api refactor
Diffstat (limited to 'src/common/input.c')
| -rw-r--r-- | src/common/input.c | 13 |
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(©, 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; } |
