Add functions to convert back to the base event

A few functions only work on the base event but once we've converted to the
target event we can't go back. Casting works for now but that would expose
internal ABI.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
This commit is contained in:
Peter Hutterer 2014-03-25 13:55:47 +10:00
parent c073003691
commit 3ece227044
2 changed files with 67 additions and 0 deletions

View file

@ -1090,3 +1090,27 @@ libinput_device_has_capability(struct libinput_device *device,
return evdev_device_has_capability((struct evdev_device *) device,
capability);
}
LIBINPUT_EXPORT struct libinput_event *
libinput_event_device_notify_get_base_event(struct libinput_event_device_notify *event)
{
return &event->base;
}
LIBINPUT_EXPORT struct libinput_event *
libinput_event_keyboard_get_base_event(struct libinput_event_keyboard *event)
{
return &event->base;
}
LIBINPUT_EXPORT struct libinput_event *
libinput_event_pointer_get_base_event(struct libinput_event_pointer *event)
{
return &event->base;
}
LIBINPUT_EXPORT struct libinput_event *
libinput_event_touch_get_base_event(struct libinput_event_touch *event)
{
return &event->base;
}

View file

@ -275,6 +275,8 @@ libinput_event_get_device(struct libinput_event *event);
* Return the pointer event that is this input event. If the event type does
* not match the pointer event types, this function returns NULL.
*
* The inverse of this function is libinput_event_pointer_get_base_event().
*
* @return A pointer event, or NULL for other events
*/
struct libinput_event_pointer *
@ -286,6 +288,8 @@ libinput_event_get_pointer_event(struct libinput_event *event);
* Return the keyboard event that is this input event. If the event type does
* not match the keyboard event types, this function returns NULL.
*
* The inverse of this function is libinput_event_keyboard_get_base_event().
*
* @return A keyboard event, or NULL for other events
*/
struct libinput_event_keyboard *
@ -297,6 +301,8 @@ libinput_event_get_keyboard_event(struct libinput_event *event);
* Return the touch event that is this input event. If the event type does
* not match the touch event types, this function returns NULL.
*
* The inverse of this function is libinput_event_touch_get_base_event().
*
* @return A touch event, or NULL for other events
*/
struct libinput_event_touch *
@ -308,11 +314,22 @@ libinput_event_get_touch_event(struct libinput_event *event);
* Return the device event that is this input event. If the event type does
* not match the device event types, this function returns NULL.
*
* The inverse of this function is
* libinput_event_device_notify_get_base_event().
*
* @return A device event, or NULL for other events
*/
struct libinput_event_device_notify *
libinput_event_get_device_notify_event(struct libinput_event *event);
/**
* @ingroup event
*
* @return The generic libinput_event of this event
*/
struct libinput_event *
libinput_event_device_notify_get_base_event(struct libinput_event_device_notify *event);
/**
* @defgroup event_keyboard Keyboard events
*
@ -344,6 +361,15 @@ libinput_event_keyboard_get_key(struct libinput_event_keyboard *event);
enum libinput_keyboard_key_state
libinput_event_keyboard_get_key_state(struct libinput_event_keyboard *event);
/**
* @ingroup event_keyboard
*
* @return The generic libinput_event of this event
*/
struct libinput_event *
libinput_event_keyboard_get_base_event(struct libinput_event_keyboard *event);
/**
* @defgroup event_pointer Pointer events
*
@ -541,6 +567,15 @@ libinput_event_pointer_get_axis(struct libinput_event_pointer *event);
li_fixed_t
libinput_event_pointer_get_axis_value(struct libinput_event_pointer *event);
/**
* @ingroup event_pointer
*
* @return The generic libinput_event of this event
*/
struct libinput_event *
libinput_event_pointer_get_base_event(struct libinput_event_pointer *event);
/**
* @defgroup event_touch Touch events
*
@ -661,6 +696,14 @@ li_fixed_t
libinput_event_touch_get_y_transformed(struct libinput_event_touch *event,
uint32_t height);
/**
* @ingroup event_touch
*
* @return The generic libinput_event of this event
*/
struct libinput_event *
libinput_event_touch_get_base_event(struct libinput_event_touch *event);
/**
* @defgroup base Initialization and manipulation of libinput contexts
*/