evdev: Fix assertion error for unplugged output with paired touchscreen
authorAnder Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
Thu, 24 Apr 2014 12:11:16 +0000 (15:11 +0300)
committerKristian Høgsberg <krh@bitplanet.net>
Fri, 25 Apr 2014 22:03:46 +0000 (15:03 -0700)
If the output a touchscreen is paired to is unplugged, events coming
from it should be ignored. Commit 17bccaed introduced logic for that
in evdev_flush_pending_damage(). However, the break statements it
introduced would cause the assertion after the switch statement to
fail.

That function has the odd behavior that goto's are used to skip the
assertion after the switch statement and jump to the hunk of code that
marks the event as processed. Only in the case where the event type has
an invalid value the assertion should trigger. So this patch fixes the
problem by moving the assertion into the default case of the switch
and replacing the goto statements with break ones.

https://bugs.freedesktop.org/show_bug.cgi?id=73950

src/evdev.c

index 9d97c87..ff951d3 100644 (file)
@@ -100,7 +100,7 @@ evdev_flush_pending_event(struct evdev_device *device, uint32_t time)
                notify_motion(master, time, device->rel.dx, device->rel.dy);
                device->rel.dx = 0;
                device->rel.dy = 0;
-               goto handled;
+               break;
        case EVDEV_ABSOLUTE_MT_DOWN:
                if (device->output == NULL)
                        break;
@@ -113,7 +113,7 @@ evdev_flush_pending_event(struct evdev_device *device, uint32_t time)
                master->slot_map |= 1 << seat_slot;
 
                notify_touch(master, time, seat_slot, x, y, WL_TOUCH_DOWN);
-               goto handled;
+               break;
        case EVDEV_ABSOLUTE_MT_MOTION:
                if (device->output == NULL)
                        break;
@@ -123,12 +123,12 @@ evdev_flush_pending_event(struct evdev_device *device, uint32_t time)
                                                   &x, &y);
                seat_slot = device->mt.slots[slot].seat_slot;
                notify_touch(master, time, seat_slot, x, y, WL_TOUCH_MOTION);
-               goto handled;
+               break;
        case EVDEV_ABSOLUTE_MT_UP:
                seat_slot = device->mt.slots[slot].seat_slot;
                master->slot_map &= ~(1 << seat_slot);
                notify_touch(master, time, seat_slot, 0, 0, WL_TOUCH_UP);
-               goto handled;
+               break;
        case EVDEV_ABSOLUTE_TOUCH_DOWN:
                if (device->output == NULL)
                        break;
@@ -141,7 +141,7 @@ evdev_flush_pending_event(struct evdev_device *device, uint32_t time)
                device->abs.seat_slot = seat_slot;
                master->slot_map |= 1 << seat_slot;
                notify_touch(master, time, seat_slot, x, y, WL_TOUCH_DOWN);
-               goto handled;
+               break;
        case EVDEV_ABSOLUTE_MOTION:
                if (device->output == NULL)
                        break;
@@ -156,17 +156,16 @@ evdev_flush_pending_event(struct evdev_device *device, uint32_t time)
                                     x, y, WL_TOUCH_MOTION);
                else if (device->seat_caps & EVDEV_SEAT_POINTER)
                        notify_motion_absolute(master, time, x, y);
-               goto handled;
+               break;
        case EVDEV_ABSOLUTE_TOUCH_UP:
                seat_slot = device->abs.seat_slot;
                master->slot_map &= ~(1 << seat_slot);
                notify_touch(master, time, seat_slot, 0, 0, WL_TOUCH_UP);
-               goto handled;
+               break;
+       default:
+               assert(0 && "Unknown pending event type");
        }
 
-       assert(0 && "Unknown pending event type");
-
-handled:
        device->pending_event = EVDEV_NONE;
 }