mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-07 13:08:04 +02: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;
|
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
|
static void
|
||||||
fallback_process_touch_button(struct fallback_dispatch *dispatch,
|
fallback_process_touch_button(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
|
|
@ -1015,14 +1040,14 @@ fallback_interface_process(struct evdev_dispatch *evdev_dispatch,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
release_touches(struct fallback_dispatch *dispatch,
|
cancel_touches(struct fallback_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
uint64_t time)
|
uint64_t time)
|
||||||
{
|
{
|
||||||
unsigned int idx;
|
unsigned int idx;
|
||||||
bool need_frame = false;
|
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++) {
|
for (idx = 0; idx < dispatch->mt.slots_len; idx++) {
|
||||||
struct mt_slot *slot = &dispatch->mt.slots[idx];
|
struct mt_slot *slot = &dispatch->mt.slots[idx];
|
||||||
|
|
@ -1030,7 +1055,7 @@ release_touches(struct fallback_dispatch *dispatch,
|
||||||
if (slot->seat_slot == -1)
|
if (slot->seat_slot == -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (fallback_flush_mt_up(dispatch, device, idx, time))
|
if (fallback_flush_mt_cancel(dispatch, device, idx, time))
|
||||||
need_frame = true;
|
need_frame = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1098,7 +1123,7 @@ fallback_return_to_neutral_state(struct fallback_dispatch *dispatch,
|
||||||
if ((time = libinput_now(libinput)) == 0)
|
if ((time = libinput_now(libinput)) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
release_touches(dispatch, device, time);
|
cancel_touches(dispatch, device, time);
|
||||||
release_pressed_keys(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->hw_key_mask));
|
||||||
memset(dispatch->hw_key_mask, 0, sizeof(dispatch->last_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 */
|
/* after disabling sendevents we require a touch up */
|
||||||
libinput_dispatch(li);
|
libinput_dispatch(li);
|
||||||
event = libinput_get_event(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);
|
libinput_event_destroy(event);
|
||||||
|
|
||||||
event = libinput_get_event(li);
|
event = libinput_get_event(li);
|
||||||
|
|
|
||||||
|
|
@ -955,7 +955,7 @@ START_TEST(touch_release_on_unplug)
|
||||||
libinput_dispatch(li);
|
libinput_dispatch(li);
|
||||||
|
|
||||||
ev = libinput_get_event(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);
|
libinput_event_destroy(ev);
|
||||||
|
|
||||||
ev = libinput_get_event(li);
|
ev = libinput_get_event(li);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue