mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-03-21 21:30:36 +01:00
fallback: cancel touches, don't just release them when we suspend
When we disable the touch device, any existing touches should be cancelled, not just released. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
cb02eca996
commit
500d03d78e
3 changed files with 33 additions and 8 deletions
|
|
@ -490,6 +490,31 @@ fallback_flush_st_up(struct fallback_dispatch *dispatch,
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
fallback_flush_st_cancel(struct fallback_dispatch *dispatch,
|
||||
struct evdev_device *device,
|
||||
uint64_t time)
|
||||
{
|
||||
struct libinput_device *base = &device->base;
|
||||
struct libinput_seat *seat = base->seat;
|
||||
int seat_slot;
|
||||
|
||||
if (!(device->seat_caps & EVDEV_DEVICE_TOUCH))
|
||||
return false;
|
||||
|
||||
seat_slot = dispatch->abs.seat_slot;
|
||||
dispatch->abs.seat_slot = -1;
|
||||
|
||||
if (seat_slot == -1)
|
||||
return false;
|
||||
|
||||
seat->slot_map &= ~(1 << seat_slot);
|
||||
|
||||
touch_notify_touch_cancel(base, time, -1, seat_slot);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
fallback_process_touch_button(struct fallback_dispatch *dispatch,
|
||||
struct evdev_device *device,
|
||||
|
|
@ -1015,14 +1040,14 @@ fallback_interface_process(struct evdev_dispatch *evdev_dispatch,
|
|||
}
|
||||
|
||||
static void
|
||||
release_touches(struct fallback_dispatch *dispatch,
|
||||
struct evdev_device *device,
|
||||
uint64_t time)
|
||||
cancel_touches(struct fallback_dispatch *dispatch,
|
||||
struct evdev_device *device,
|
||||
uint64_t time)
|
||||
{
|
||||
unsigned int idx;
|
||||
bool need_frame = false;
|
||||
|
||||
need_frame = fallback_flush_st_up(dispatch, device, time);
|
||||
need_frame = fallback_flush_st_cancel(dispatch, device, time);
|
||||
|
||||
for (idx = 0; idx < dispatch->mt.slots_len; idx++) {
|
||||
struct mt_slot *slot = &dispatch->mt.slots[idx];
|
||||
|
|
@ -1030,7 +1055,7 @@ release_touches(struct fallback_dispatch *dispatch,
|
|||
if (slot->seat_slot == -1)
|
||||
continue;
|
||||
|
||||
if (fallback_flush_mt_up(dispatch, device, idx, time))
|
||||
if (fallback_flush_mt_cancel(dispatch, device, idx, time))
|
||||
need_frame = true;
|
||||
}
|
||||
|
||||
|
|
@ -1098,7 +1123,7 @@ fallback_return_to_neutral_state(struct fallback_dispatch *dispatch,
|
|||
if ((time = libinput_now(libinput)) == 0)
|
||||
return;
|
||||
|
||||
release_touches(dispatch, device, time);
|
||||
cancel_touches(dispatch, device, time);
|
||||
release_pressed_keys(dispatch, device, time);
|
||||
memset(dispatch->hw_key_mask, 0, sizeof(dispatch->hw_key_mask));
|
||||
memset(dispatch->hw_key_mask, 0, sizeof(dispatch->last_hw_key_mask));
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ START_TEST(device_disable_touch_during_touch)
|
|||
/* after disabling sendevents we require a touch up */
|
||||
libinput_dispatch(li);
|
||||
event = libinput_get_event(li);
|
||||
litest_is_touch_event(event, LIBINPUT_EVENT_TOUCH_UP);
|
||||
litest_is_touch_event(event, LIBINPUT_EVENT_TOUCH_CANCEL);
|
||||
libinput_event_destroy(event);
|
||||
|
||||
event = libinput_get_event(li);
|
||||
|
|
|
|||
|
|
@ -955,7 +955,7 @@ START_TEST(touch_release_on_unplug)
|
|||
libinput_dispatch(li);
|
||||
|
||||
ev = libinput_get_event(li);
|
||||
litest_is_touch_event(ev, LIBINPUT_EVENT_TOUCH_UP);
|
||||
litest_is_touch_event(ev, LIBINPUT_EVENT_TOUCH_CANCEL);
|
||||
libinput_event_destroy(ev);
|
||||
|
||||
ev = libinput_get_event(li);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue