[PATCH libinput] Add libinput_device_get_context/libinput_seat_get_context

Hans de Goede hdegoede at redhat.com
Tue Dec 2 00:13:27 PST 2014


Hi,

On 12/02/2014 12:45 AM, Peter Hutterer wrote:
> Allow retrieval of the libinput context from the seat and the device.
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

Looks good.

Reviewed-by: Hans de Goede <hdegoede at redhat.com>

Regards,

Hans

> ---
>   src/libinput.c | 12 ++++++++++++
>   src/libinput.h | 22 ++++++++++++++++++++++
>   test/device.c  | 12 ++++++++++++
>   3 files changed, 46 insertions(+)
>
> diff --git a/src/libinput.c b/src/libinput.c
> index 96b255a..0d380fa 100644
> --- a/src/libinput.c
> +++ b/src/libinput.c
> @@ -651,6 +651,12 @@ libinput_seat_get_user_data(struct libinput_seat *seat)
>   	return seat->user_data;
>   }
>
> +LIBINPUT_EXPORT struct libinput *
> +libinput_seat_get_context(struct libinput_seat *seat)
> +{
> +	return seat->libinput;
> +}
> +
>   LIBINPUT_EXPORT const char *
>   libinput_seat_get_physical_name(struct libinput_seat *seat)
>   {
> @@ -1177,6 +1183,12 @@ libinput_device_get_user_data(struct libinput_device *device)
>   	return device->user_data;
>   }
>
> +LIBINPUT_EXPORT struct libinput *
> +libinput_device_get_context(struct libinput_device *device)
> +{
> +	return libinput_seat_get_context(device->seat);
> +}
> +
>   LIBINPUT_EXPORT const char *
>   libinput_device_get_sysname(struct libinput_device *device)
>   {
> diff --git a/src/libinput.h b/src/libinput.h
> index d567df4..db56da7 100644
> --- a/src/libinput.h
> +++ b/src/libinput.h
> @@ -1202,6 +1202,17 @@ libinput_seat_get_user_data(struct libinput_seat *seat);
>   /**
>    * @ingroup seat
>    *
> + * Get the libinput context from the seat.
> + *
> + * @param seat A previously obtained seat
> + * @return The libinput context for this seat.
> + */
> +struct libinput *
> +libinput_seat_get_context(struct libinput_seat *seat);
> +
> +/**
> + * @ingroup seat
> + *
>    * Return the physical name of the seat. For libinput contexts created from
>    * udev, this is always the same value as passed into
>    * libinput_udev_assign_seat() and all seats from that context will have
> @@ -1291,6 +1302,17 @@ libinput_device_get_user_data(struct libinput_device *device);
>   /**
>    * @ingroup device
>    *
> + * Get the libinput context from the device.
> + *
> + * @param device A previously obtained device
> + * @return The libinput context for this device.
> + */
> +struct libinput *
> +libinput_device_get_context(struct libinput_device *device);
> +
> +/**
> + * @ingroup device
> + *
>    * Get the system name of the device.
>    *
>    * To get the descriptive device name, use libinput_device_get_name().
> diff --git a/test/device.c b/test/device.c
> index 84984f4..28cdb06 100644
> --- a/test/device.c
> +++ b/test/device.c
> @@ -629,6 +629,17 @@ START_TEST(device_get_udev_handle)
>   }
>   END_TEST
>
> +START_TEST(device_context)
> +{
> +	struct litest_device *dev = litest_current_device();
> +	struct libinput_seat *seat;
> +
> +	ck_assert(dev->libinput == libinput_device_get_context(dev->libinput_device));
> +	seat = libinput_device_get_seat(dev->libinput_device);
> +	ck_assert(dev->libinput == libinput_seat_get_context(seat));
> +}
> +END_TEST
> +
>   int main (int argc, char **argv)
>   {
>   	litest_add("device:sendevents", device_sendevents_config, LITEST_ANY, LITEST_TOUCHPAD);
> @@ -650,6 +661,7 @@ int main (int argc, char **argv)
>   	litest_add("device:sendevents", device_disable_release_softbutton, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
>   	litest_add("device:sendevents", device_disable_topsoftbutton, LITEST_TOPBUTTONPAD, LITEST_ANY);
>   	litest_add("device:id", device_ids, LITEST_ANY, LITEST_ANY);
> +	litest_add_for_device("device:context", device_context, LITEST_SYNAPTICS_CLICKPAD);
>
>   	litest_add("device:udev", device_get_udev_handle, LITEST_ANY, LITEST_ANY);
>
>


More information about the wayland-devel mailing list