From 72cfef9a5676f71fc998d1d1925755d853369229 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 4 Mar 2022 13:40:21 +1000 Subject: [PATCH] eis: don't allow for region changes once the region was added --- src/libeis-region.c | 9 +++++++++ src/libeis.h | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/src/libeis-region.c b/src/libeis-region.c index 376dcdd..c35c06c 100644 --- a/src/libeis-region.c +++ b/src/libeis-region.c @@ -72,6 +72,9 @@ eis_device_new_region(struct eis_device *device) _public_ void eis_region_set_offset(struct eis_region *region, uint32_t x, uint32_t y) { + if (region->added_to_device) + return; + region->x = x; region->y = y; } @@ -79,6 +82,9 @@ eis_region_set_offset(struct eis_region *region, uint32_t x, uint32_t y) _public_ void eis_region_set_size(struct eis_region *region, uint32_t w, uint32_t h) { + if (region->added_to_device) + return; + region->width = w; region->height = h; } @@ -86,6 +92,9 @@ eis_region_set_size(struct eis_region *region, uint32_t w, uint32_t h) _public_ void eis_region_set_physical_scale(struct eis_region *region, double scale) { + if (region->added_to_device) + return; + if (scale > 0.0) region->physical_scale = scale; } diff --git a/src/libeis.h b/src/libeis.h index edcd933..60c1219 100644 --- a/src/libeis.h +++ b/src/libeis.h @@ -622,9 +622,15 @@ eis_device_configure_capability(struct eis_device *device, enum eis_device_capab struct eis_region * eis_device_new_region(struct eis_device *device); +/** + * This call has no effect if called after eis_region_add() + */ void eis_region_set_size(struct eis_region *region, uint32_t w, uint32_t h); +/** + * This call has no effect if called after eis_region_add() + */ void eis_region_set_offset(struct eis_region *region, uint32_t x, uint32_t y); @@ -634,6 +640,8 @@ eis_region_set_offset(struct eis_region *region, uint32_t x, uint32_t y); * * A @a scale value of less or equal to 0.0 will be silently ignored. * + * This call has no effect if called after eis_region_add() + * * See ei_region_get_physical_scale() for details. */ void