Add libinput_event_get_context()

Add a function to retrieve the libinput context from any event.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2013-12-19 11:22:53 +10:00 committed by Jonas Ådahl
parent 31a8a29cef
commit 06453ba7a5
2 changed files with 22 additions and 2 deletions

View file

@ -50,6 +50,7 @@ struct libinput_source {
struct libinput_event {
enum libinput_event_type type;
struct libinput *libinput;
union libinput_event_target target;
};
@ -133,6 +134,12 @@ libinput_event_get_target(struct libinput_event *event)
return event->target;
}
LIBINPUT_EXPORT struct libinput*
libinput_event_get_context(struct libinput_event *event)
{
return event->libinput;
}
LIBINPUT_EXPORT struct libinput_seat *
libinput_event_added_seat_get_seat(struct libinput_event_added_seat *event)
{
@ -596,10 +603,12 @@ libinput_dispatch(struct libinput *libinput)
static void
init_event_base(struct libinput_event *event,
struct libinput *libinput,
enum libinput_event_type type,
union libinput_event_target target)
{
event->type = type;
event->libinput = libinput;
event->target = target;
}
@ -608,7 +617,7 @@ post_base_event(struct libinput *libinput,
enum libinput_event_type type,
struct libinput_event *event)
{
init_event_base(event, type,
init_event_base(event, libinput, type,
(union libinput_event_target) { .libinput = libinput });
libinput_post_event(libinput, event);
}
@ -618,7 +627,7 @@ post_device_event(struct libinput_device *device,
enum libinput_event_type type,
struct libinput_event *event)
{
init_event_base(event, type,
init_event_base(event, device->seat->libinput, type,
(union libinput_event_target) { .device = device });
libinput_post_event(device->seat->libinput, event);
}

View file

@ -240,6 +240,17 @@ libinput_event_get_type(struct libinput_event *event);
union libinput_event_target
libinput_event_get_target(struct libinput_event *event);
/**
* @ingroup event
*
* Get the libinput context from the event.
*
* @param event The libinput event
* @return The libinput context for this event.
*/
struct libinput*
libinput_event_get_context(struct libinput_event *event);
/**
* @defgroup event_added_seat Added seat event
*/