From 81cb24124d183d73f096c307dc26dc1968c86220 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 13 Aug 2020 13:05:50 +1000 Subject: [PATCH] libei: drop the nested event types There's relatively little benefit here since we won't have a lot of different events and any caller will do the switch based on the event type anyway. So let's just export a single event type and have everything contained in that. Signed-off-by: Peter Hutterer --- src/libei-private.h | 4 ---- src/libei.c | 37 +++++++++++++++---------------------- src/libei.h | 18 +----------------- 3 files changed, 16 insertions(+), 43 deletions(-) diff --git a/src/libei-private.h b/src/libei-private.h index 178b595..4f24edc 100644 --- a/src/libei-private.h +++ b/src/libei-private.h @@ -80,10 +80,6 @@ struct ei_event { struct ei_device *device; }; -struct ei_event_client { - struct ei_event base; -}; - void ei_init_object(struct ei *ei, struct object *parent); diff --git a/src/libei.c b/src/libei.c index 646d28a..9acea3b 100644 --- a/src/libei.c +++ b/src/libei.c @@ -94,8 +94,7 @@ ei_event_destroy(struct ei_event *event) ei_device_unref(event->device); } -static -OBJECT_IMPLEMENT_INIT(ei_event); +OBJECT_IMPLEMENT_CREATE(ei_event); static OBJECT_IMPLEMENT_REF(ei_event); _public_ @@ -179,21 +178,19 @@ ei_queue_event(struct ei *ei, struct ei_event *event) static void ei_queue_connect_event(struct ei *ei) { - struct ei_event_client *e = xalloc(sizeof(*e)); - ei_event_init_object(&e->base, &ei->object); - e->base.type = EI_EVENT_CONNECT; + struct ei_event *e = ei_event_create(&ei->object); + e->type = EI_EVENT_CONNECT; - ei_queue_event(ei, &e->base); + ei_queue_event(ei, e); } static void ei_queue_disconnect_event(struct ei *ei) { - struct ei_event_client *e = xalloc(sizeof(*e)); - ei_event_init_object(&e->base, &ei->object); - e->base.type = EI_EVENT_DISCONNECT; + struct ei_event *e = ei_event_create(&ei->object); + e->type = EI_EVENT_DISCONNECT; - ei_queue_event(ei, &e->base); + ei_queue_event(ei, e); } static void @@ -201,12 +198,11 @@ ei_queue_added_event(struct ei_device *device) { struct ei *ei= ei_device_get_context(device); - struct ei_event_client *e = xalloc(sizeof(*e)); - ei_event_init_object(&e->base, &ei->object); - e->base.type = EI_EVENT_DEVICE_ADDED; - e->base.device = ei_device_ref(device); + struct ei_event *e = ei_event_create(&ei->object); + e->type = EI_EVENT_DEVICE_ADDED; + e->device = ei_device_ref(device); - ei_queue_event(ei, &e->base); + ei_queue_event(ei, e); } static void @@ -214,14 +210,11 @@ ei_queue_removed_event(struct ei_device *device) { struct ei *ei= ei_device_get_context(device); - log_debug(ei, "queuing removed event\n"); + struct ei_event *e = ei_event_create(&ei->object); + e->type = EI_EVENT_DEVICE_REMOVED; + e->device = ei_device_ref(device); - struct ei_event_client *e = xalloc(sizeof(*e)); - ei_event_init_object(&e->base, &ei->object); - e->base.type = EI_EVENT_DEVICE_REMOVED; - e->base.device = ei_device_ref(device); - - ei_queue_event(ei, &e->base); + ei_queue_event(ei, e); } static int diff --git a/src/libei.h b/src/libei.h index 5c9fbf5..3b1c62f 100644 --- a/src/libei.h +++ b/src/libei.h @@ -29,10 +29,6 @@ struct ei; struct ei_device; struct ei_event; -struct ei_event_client; -struct ei_event_pointer; -struct ei_event_keyboard; -struct ei_event_touch; enum ei_device_capability { EI_DEVICE_CAP_POINTER = 1, @@ -584,16 +580,4 @@ ei_event_get_device(struct ei_event *event); * @return the event time in microseconds */ uint64_t -ei_event_pointer_get_time(struct ei_event_pointer *event); - -/** - * @return the event time in microseconds - */ -uint64_t -ei_event_keyboard_get_time(struct ei_event_keyboard *event); - -/** - * @return the event time in microseconds - */ -uint64_t -ei_event_touch_get_time(struct ei_event_touch *event); +ei_event_get_time(struct ei_event *event);