mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2025-12-30 16:30:16 +01:00
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: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/340>
This commit is contained in:
parent
525d55a532
commit
1010cdff3c
3 changed files with 22 additions and 16 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
34
src/libeis.c
34
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue