eis: don't allow for region changes once the region was added

This commit is contained in:
Peter Hutterer 2022-03-04 13:40:21 +10:00
parent 9f1db1e10b
commit 72cfef9a56
2 changed files with 17 additions and 0 deletions

View file

@ -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;
}

View file

@ -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