tools/demo-server: check if we have a touch before sending one

If the client was disconnected, the returned touch is NULL. Check for
that instead of blindly assuming we can send the touch.
This commit is contained in:
Peter Hutterer 2023-04-13 11:20:22 +10:00
parent 2a178f416f
commit 3e39dabeac

View file

@ -741,21 +741,27 @@ int main(int argc, char **argv)
switch (counter++ % 5) {
case 0:
colorprint("sending touch down event\n");
touch = eis_device_touch_new(touchscreen);
eis_touch_down(touch, 100 + ++x, 200 - ++y);
eis_device_frame(touchscreen, now);
democlient->touch = touch;
if (touch) { /* NULL if client was disconnected internally already */
colorprint("sending touch down event\n");
eis_touch_down(touch, 100 + ++x, 200 - ++y);
eis_device_frame(touchscreen, now);
democlient->touch = touch;
}
break;
case 4:
colorprint("sending touch down event\n");
eis_touch_up(touch);
eis_device_frame(touchscreen, now);
democlient->touch = eis_touch_unref(touch);
if (touch) {
colorprint("sending touch down event\n");
eis_touch_up(touch);
eis_device_frame(touchscreen, now);
democlient->touch = eis_touch_unref(touch);
}
break;
default:
eis_touch_motion(touch, 100 + ++x, 200 - ++y);
eis_device_frame(touchscreen, now);
if (touch) {
eis_touch_motion(touch, 100 + ++x, 200 - ++y);
eis_device_frame(touchscreen, now);
}
break;
}