Commit 500d03d7 authored by Peter Hutterer's avatar Peter Hutterer

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's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent cb02eca9
Pipeline #4920 passed with stages
in 6 minutes and 31 seconds
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment