From 1010cdff3c6764ef3ad36b0865ee5d37cffd0a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 26 Jun 2025 13:04:04 +0200 Subject: [PATCH] eis: Send sync done event on last event unref This allows the application to hold the sync event for a while longer, e.g. to ensure previous events from EIS have passed through relevant plumbing and reached their internally intended targets, which might happen synchronously between each processed EIS event. Part-of: --- src/libeis-event.c | 1 + src/libeis-private.h | 3 +++ src/libeis.c | 34 ++++++++++++++++++---------------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/libeis-event.c b/src/libeis-event.c index c002a5e..d073035 100644 --- a/src/libeis-event.c +++ b/src/libeis-event.c @@ -63,6 +63,7 @@ eis_event_destroy(struct eis_event *event) handled = true; break; case EIS_EVENT_SYNC: + eis_sync_event_send_done(event); eis_callback_unref(event->sync.callback); handled = true; break; diff --git a/src/libeis-private.h b/src/libeis-private.h index caff3ed..92aee30 100644 --- a/src/libeis-private.h +++ b/src/libeis-private.h @@ -155,6 +155,9 @@ eis_queue_touch_up_event(struct eis_device *device, uint32_t touchid); void eis_queue_touch_cancel_event(struct eis_device *device, uint32_t touchid); +void +eis_sync_event_send_done(struct eis_event *e); + _printf_(6, 7) void eis_log_msg(struct eis *eis, enum eis_log_priority priority, diff --git a/src/libeis.c b/src/libeis.c index c3ddec0..42bc386 100644 --- a/src/libeis.c +++ b/src/libeis.c @@ -256,6 +256,24 @@ eis_queue_device_closed_event(struct eis_device *device) eis_queue_event(e); } +void +eis_sync_event_send_done(struct eis_event *e) +{ + _unref_(eis_callback) *callback = steal(&e->sync.callback); + log_debug(eis_event_get_context(e) , + "object %#" PRIx64 ": connection sync done", + eis_callback_get_id(callback)); + + int rc = eis_callback_event_done(callback, 0); + _unref_(brei_result) *result = brei_result_new_from_neg_errno(rc); + if (result) { + struct eis_client *client = eis_event_get_client(e); + eis_client_disconnect_with_reason(client, + brei_result_get_reason(result), + brei_result_get_explanation(result)); + } +} + void eis_queue_sync_event(struct eis_client *client, object_id_t newid, uint32_t version) { @@ -439,22 +457,6 @@ eis_get_event(struct eis *eis) struct eis_event *e = list_first_entry(&eis->event_queue, e, link); list_remove(&e->link); - if (e->type == EIS_EVENT_SYNC) { - _unref_(eis_callback) *callback = steal(&e->sync.callback); - log_debug(eis_event_get_context(e) , - "object %#" PRIx64 ": connection sync done", - eis_callback_get_id(callback)); - - int rc = eis_callback_event_done(callback, 0); - _unref_(brei_result) *result = brei_result_new_from_neg_errno(rc); - if (result) { - struct eis_client *client = eis_event_get_client(e); - eis_client_disconnect_with_reason(client, - brei_result_get_reason(result), - brei_result_get_explanation(result)); - } - } - return e; }