evdev: release touch events when a device is removed 62/149462/1 tizen_3.0_tv
authorJengHyun Kang <jhyuni.kang@samsung.com>
Tue, 12 Sep 2017 08:16:05 +0000 (17:16 +0900)
committerJeongHyun Kang <jhyuni.kang@samsung.com>
Tue, 12 Sep 2017 08:56:51 +0000 (08:56 +0000)
Change-Id: I095fac943ac91fa1bf39fd127044b18f46dec8c4

src/evdev.c

index ababc5b1f260f5a36ca2ca7d147ff7c4bd7ebf60..51f57bb3b5c2fede32b38ef7af2b0557ae82e6be 100644 (file)
@@ -2204,6 +2204,54 @@ evdev_stop_scroll(struct evdev_device *device,
        device->scroll.direction = 0;
 }
 
+static void
+release_touches(struct evdev_device *device)
+{
+       unsigned int idx;
+       int seat_slot;
+       struct libinput_device *base = &device->base;
+       struct libinput_seat *seat = base->seat;
+       bool need_frame = false;
+       uint64_t time;
+
+       struct libinput *libinput = device->base.seat->libinput;
+
+       if ((time = libinput_now(libinput)) == 0)
+               return;
+
+       if (!(device->seat_caps & EVDEV_DEVICE_TOUCH))
+               return;
+
+       seat_slot = device->abs.seat_slot;
+       device->abs.seat_slot = -1;
+
+       if (seat_slot != -1) {
+               seat->slot_map &= ~(1 << seat_slot);
+               touch_notify_touch_up(base, time, -1, seat_slot);
+               need_frame = true;
+       }
+
+       for (idx = 0; idx < device->mt.slots_len; idx++) {
+               struct mt_slot *slot = &device->mt.slots[idx];
+
+               seat_slot = slot->seat_slot;
+               slot->seat_slot = -1;
+
+               if (seat_slot == -1)
+                       continue;
+
+               seat->slot_map &= ~(1 << seat_slot);
+
+               evdev_flush_extra_aux_data(device, time, device->pending_event, idx, seat_slot);
+               touch_notify_touch_up(base, time, idx, seat_slot);
+
+               need_frame = true;
+       }
+
+       if (need_frame)
+               touch_notify_frame(&device->base, time);
+}
+
 static void
 release_pressed_keys(struct evdev_device *device)
 {
@@ -2298,6 +2346,7 @@ evdev_device_suspend(struct evdev_device *device)
                device->source = NULL;
        }
 
+       release_touches(device);
        release_pressed_keys(device);
 
        if (device->mtdev) {