From: JengHyun Kang Date: Tue, 12 Sep 2017 08:16:05 +0000 (+0900) Subject: evdev: release touch events when a device is removed X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Ftizen_3.0;p=platform%2Fupstream%2Flibinput.git evdev: release touch events when a device is removed Change-Id: I383e47e0b77f28a34ed14c5e25497f47ff4b1552 --- diff --git a/src/evdev.c b/src/evdev.c index 395b8bcc..75b14c54 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -2203,6 +2203,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) { @@ -2297,6 +2345,7 @@ evdev_device_suspend(struct evdev_device *device) device->source = NULL; } + release_touches(device); release_pressed_keys(device); if (device->mtdev) {