mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-02-15 09:10:34 +01:00
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 <peter.hutterer@who-t.net>
This commit is contained in:
parent
b547fdc529
commit
81cb24124d
3 changed files with 16 additions and 43 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
37
src/libei.c
37
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
|
||||
|
|
|
|||
18
src/libei.h
18
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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue