Drop event classes
authorPeter Hutterer <peter.hutterer@who-t.net>
Tue, 21 Jan 2014 03:56:12 +0000 (13:56 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Wed, 22 Jan 2014 01:16:29 +0000 (11:16 +1000)
There are now only two event classes and only two users of the event class.
It's easier to use the event type directly to see which event has references
and which one doesn't.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
src/libinput.c

index 6899163f2d5cc170d57db05f71ed9e0b8aeaae1a..2413c8ed0b26b26f0617b7bb6e9780502d3d534f 100644 (file)
 #include "libinput-private.h"
 #include "evdev.h"
 
-enum libinput_event_class {
-       LIBINPUT_EVENT_CLASS_NONE,
-       LIBINPUT_EVENT_CLASS_BASE,
-       LIBINPUT_EVENT_CLASS_SEAT,
-       LIBINPUT_EVENT_CLASS_DEVICE,
-};
-
 struct libinput_source {
        libinput_source_dispatch_t dispatch;
        void *user_data;
@@ -432,17 +425,18 @@ libinput_destroy(struct libinput *libinput)
        free(libinput);
 }
 
-static enum libinput_event_class
-libinput_event_get_class(struct libinput_event *event)
+LIBINPUT_EXPORT void
+libinput_event_destroy(struct libinput_event *event)
 {
-       switch (event->type) {
-       case LIBINPUT_EVENT_NONE:
-               return LIBINPUT_EVENT_CLASS_NONE;
+       if (event == NULL)
+               return;
 
+       switch (libinput_event_get_type(event)) {
+       case LIBINPUT_EVENT_NONE:
+               abort(); /* not used as actual event type */
        case LIBINPUT_EVENT_DEVICE_ADDED:
        case LIBINPUT_EVENT_DEVICE_REMOVED:
-               return LIBINPUT_EVENT_CLASS_BASE;
-
+               break;
        case LIBINPUT_EVENT_KEYBOARD_KEY:
        case LIBINPUT_EVENT_POINTER_MOTION:
        case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
@@ -450,27 +444,6 @@ libinput_event_get_class(struct libinput_event *event)
        case LIBINPUT_EVENT_POINTER_AXIS:
        case LIBINPUT_EVENT_TOUCH_TOUCH:
        case LIBINPUT_EVENT_TOUCH_FRAME:
-               return LIBINPUT_EVENT_CLASS_DEVICE;
-       }
-
-       /* We should never end up here. */
-       abort();
-}
-
-LIBINPUT_EXPORT void
-libinput_event_destroy(struct libinput_event *event)
-{
-       if (event == NULL)
-               return;
-
-       switch (libinput_event_get_class(event)) {
-       case LIBINPUT_EVENT_CLASS_NONE:
-       case LIBINPUT_EVENT_CLASS_BASE:
-               break;
-       case LIBINPUT_EVENT_CLASS_SEAT:
-               libinput_seat_unref(event->device->seat);
-               break;
-       case LIBINPUT_EVENT_CLASS_DEVICE:
                libinput_device_unref(event->device);
                break;
        }
@@ -877,14 +850,19 @@ libinput_post_event(struct libinput *libinput,
                libinput->events_len = events_len;
        }
 
-       switch (libinput_event_get_class(event)) {
-       case LIBINPUT_EVENT_CLASS_NONE:
-       case LIBINPUT_EVENT_CLASS_BASE:
-               break;
-       case LIBINPUT_EVENT_CLASS_SEAT:
-               libinput_seat_ref(event->device->seat);
+       switch (libinput_event_get_type(event)) {
+       case LIBINPUT_EVENT_NONE:
+               abort(); /* not used as actual event type */
+       case LIBINPUT_EVENT_DEVICE_ADDED:
+       case LIBINPUT_EVENT_DEVICE_REMOVED:
                break;
-       case LIBINPUT_EVENT_CLASS_DEVICE:
+       case LIBINPUT_EVENT_KEYBOARD_KEY:
+       case LIBINPUT_EVENT_POINTER_MOTION:
+       case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
+       case LIBINPUT_EVENT_POINTER_BUTTON:
+       case LIBINPUT_EVENT_POINTER_AXIS:
+       case LIBINPUT_EVENT_TOUCH_TOUCH:
+       case LIBINPUT_EVENT_TOUCH_FRAME:
                libinput_device_ref(event->device);
                break;
        }