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-Tag: submit/tizen/20170912.103924^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Faccepted%2Ftizen_4.0_unified;p=platform%2Fupstream%2Flibinput.git evdev: release touch events when a device is removed Change-Id: I095fac943ac91fa1bf39fd127044b18f46dec8c4 --- diff --git a/src/evdev.c b/src/evdev.c index bab08778..74729a86 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -2205,6 +2205,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) { @@ -2299,6 +2347,7 @@ evdev_device_suspend(struct evdev_device *device) device->source = NULL; } + release_touches(device); release_pressed_keys(device); if (device->mtdev) {