From 5b286a4d3ada28bf17eaed3c4053a07eae12d95d Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 5 May 2022 13:46:26 +1000 Subject: [PATCH] ei: add receiver handling for empty/flushing frame events Where the sender sends empty frame events, or a device event without a subsequent frame events ensure that event is filtered or emulated in our event queue. Note: because of our sender filters, we cannot actually test this, at least not easily. Let's hope it works. --- src/libei.c | 3 --- src/libeis-private.h | 1 + src/libeis.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/libei.c b/src/libei.c index 5885b3a..c5a7f5c 100644 --- a/src/libei.c +++ b/src/libei.c @@ -215,18 +215,15 @@ queue_event(struct ei *ei, struct ei_event *event) case EI_EVENT_TOUCH_UP: case EI_EVENT_TOUCH_MOTION: device->queue_frame_event = true; - log_debug(ei, "here\n"); break; case EI_EVENT_FRAME: /* silently discard empty frames */ if (!device->queue_frame_event) return; - log_debug(ei, "queue frame\n"); device->queue_frame_event = false; break; default: - log_debug(ei, "other: %s\n", ei_event_type_to_string(event->type)); if (device) { if (device->queue_frame_event) ei_queue_frame_event(device); diff --git a/src/libeis-private.h b/src/libeis-private.h index 94ec6ed..154a53f 100644 --- a/src/libeis-private.h +++ b/src/libeis-private.h @@ -143,6 +143,7 @@ struct eis_device { struct eis_keymap *keymap; bool send_frame_event; + bool queue_frame_event; struct { bool x_is_stopped, y_is_stopped; diff --git a/src/libeis.c b/src/libeis.c index af47e60..a224e7e 100644 --- a/src/libeis.c +++ b/src/libeis.c @@ -138,6 +138,37 @@ static void eis_queue_event(struct eis_event *event) { struct eis *eis = eis_event_get_context(event); + struct eis_device *device = eis_event_get_device(event); + + switch (event->type) { + case EIS_EVENT_POINTER_MOTION: + case EIS_EVENT_POINTER_MOTION_ABSOLUTE: + case EIS_EVENT_POINTER_BUTTON: + case EIS_EVENT_POINTER_SCROLL: + case EIS_EVENT_POINTER_SCROLL_STOP: + case EIS_EVENT_POINTER_SCROLL_CANCEL: + case EIS_EVENT_POINTER_SCROLL_DISCRETE: + case EIS_EVENT_KEYBOARD_KEY: + case EIS_EVENT_TOUCH_DOWN: + case EIS_EVENT_TOUCH_UP: + case EIS_EVENT_TOUCH_MOTION: + device->queue_frame_event = true; + break; + case EIS_EVENT_FRAME: + /* silently discard empty frames */ + if (!device->queue_frame_event) + return; + + device->queue_frame_event = false; + break; + default: + if (device) { + if (device->queue_frame_event) + eis_queue_frame_event(device); + device->queue_frame_event = false; + } + break; + } log_debug(eis, "queuing event type %s (%u)\n", eis_event_type_to_string(event->type), event->type);