diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2011-12-14 14:53:52 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2011-12-20 13:01:00 +1000 |
commit | 7f8127d203394cae45c3ded0d063030d7c5fdb70 (patch) | |
tree | aef5214e359f8acdf2795df2a74ae835958c3a4e /test/touch.c | |
parent | 758bc57ba5a89f765d83f0b169aa09e79a89bf89 (diff) |
dix: if we run out of space for new touch events, resize the queue
The SIGIO handler forces us to drop the current touch and schedule the
actual resize for later. Should not happen if the device sets up the
TouchClassRec with the correct number of touchpoints.
Co-authored-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Diffstat (limited to 'test/touch.c')
-rw-r--r-- | test/touch.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/test/touch.c b/test/touch.c index 5b8e567cc..1ea8f0ca5 100644 --- a/test/touch.c +++ b/test/touch.c @@ -29,6 +29,56 @@ #include "inputstr.h" #include "assert.h" +static void touch_grow_queue(void) +{ + DeviceIntRec dev; + ValuatorClassRec val; + TouchClassRec touch; + size_t size, new_size; + int i; + + memset(&dev, 0, sizeof(dev)); + dev.id = 2; + dev.valuator = &val; + val.numAxes = 5; + dev.touch = &touch; + inputInfo.devices = &dev; + + size = 5; + + dev.last.num_touches = size; + dev.last.touches = calloc(dev.last.num_touches, sizeof(*dev.last.touches)); + assert(dev.last.touches); + for (i = 0; i < size; i++) { + dev.last.touches[i].active = TRUE; + dev.last.touches[i].ddx_id = i; + dev.last.touches[i].client_id = i * 2; + } + + /* no more space, should've scheduled a workproc */ + assert(TouchBeginDDXTouch(&dev, 1234) == NULL); + ProcessWorkQueue(); + + new_size = size + size/2 + 1; + assert(dev.last.num_touches == new_size); + + /* make sure we haven't touched those */ + for (i = 0; i < size; i++) { + DDXTouchPointInfoPtr t = &dev.last.touches[i]; + assert(t->active == TRUE); + assert(t->ddx_id == i); + assert(t->client_id == i * 2); + } + + /* make sure those are zero-initialized */ + for (i = size; i < new_size; i++) { + DDXTouchPointInfoPtr t = &dev.last.touches[i]; + assert(t->active == FALSE); + assert(t->client_id == 0); + assert(t->ddx_id == 0); + } +} + static void touch_find_ddxid(void) { DeviceIntRec dev; @@ -142,6 +192,7 @@ static void touch_begin_ddxtouch(void) int main(int argc, char** argv) { + touch_grow_queue(); touch_find_ddxid(); touch_begin_ddxtouch(); |