From d5bdcfc0daaa758a97771ff84a232def87b1659b Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 3 Mar 2022 11:24:51 +1000 Subject: [PATCH] eis: add the functions to fetch a region back from the device Same as ei_device_get_region() and friends. --- src/libeis-device.c | 6 ++++++ src/libeis-region.c | 8 ++++++++ src/libeis.h | 31 +++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/src/libeis-device.c b/src/libeis-device.c index 5a0c179..15a84f7 100644 --- a/src/libeis-device.c +++ b/src/libeis-device.c @@ -158,6 +158,12 @@ eis_device_get_seat(struct eis_device *device) return eis_device_parent(device); } +_public_ struct eis_region * +eis_device_get_region(struct eis_device *device, size_t index) +{ + return list_nth_entry(struct eis_region, &device->regions, link, index); +} + _public_ void eis_device_set_name(struct eis_device *device, const char *name) { diff --git a/src/libeis-region.c b/src/libeis-region.c index 2ee8db1..7b66387 100644 --- a/src/libeis-region.c +++ b/src/libeis-region.c @@ -42,6 +42,14 @@ _public_ OBJECT_IMPLEMENT_GETTER(eis_region, user_data, void *); _public_ OBJECT_IMPLEMENT_SETTER(eis_region, user_data, void *); +_public_ +OBJECT_IMPLEMENT_GETTER(eis_region, x, uint32_t); +_public_ +OBJECT_IMPLEMENT_GETTER(eis_region, y, uint32_t); +_public_ +OBJECT_IMPLEMENT_GETTER(eis_region, width, uint32_t); +_public_ +OBJECT_IMPLEMENT_GETTER(eis_region, height, uint32_t); static OBJECT_IMPLEMENT_CREATE(eis_region); diff --git a/src/libeis.h b/src/libeis.h index 11c2cfa..0e27b2e 100644 --- a/src/libeis.h +++ b/src/libeis.h @@ -604,6 +604,25 @@ eis_region_set_physical_scale(struct eis_region *region, double scale); void eis_region_add(struct eis_region *region); +/** + * Obtain a region from the device. This function only returns regions that + * have been added to the device with eis_region_add(). The number of regions + * is constant for a device once eis_device_add() has been called and the + * indices of any region remains the same for the lifetime of + * the device. + * + * Regions are shared between all capabilities. Where two capabilities need + * different region, the EIS implementation must create multiple devices with + * individual capabilities and regions. + * + * This function returns the given region or NULL if the index is larger than + * the number of regions available. + * + * This does not increase the refcount of the region. Use eis_region_ref() to + * keep a reference beyond the immediate scope. + */ +struct eis_region * +eis_device_get_region(struct eis_device *device, size_t index); struct eis_region * eis_region_ref(struct eis_region *region); @@ -617,6 +636,18 @@ eis_region_get_user_data(struct eis_region *region); void eis_region_set_user_data(struct eis_region *region, void *user_data); +uint32_t +eis_region_get_x(struct eis_region *region); + +uint32_t +eis_region_get_y(struct eis_region *region); + +uint32_t +eis_region_get_width(struct eis_region *region); + +uint32_t +eis_region_get_height(struct eis_region *region); + /** * Add this device to its seat and notify the client of the device's * availability.