diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2016-08-03 11:58:23 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2016-09-07 11:17:03 +1000 |
commit | b0ec4bacbdbada042f23ccf1bcc382ff754972c2 (patch) | |
tree | fc25fc11bfaf84bcfae4ab50027e33393c1337f4 | |
parent | b26d8f91228156cee1a3016f60132aa0190e6ebb (diff) |
evdev: let the fallback_flush... function decide whether a frame is needed
Rather than testing before if we have an event that matches the need for a
frame simply return the event sent by the flush function. If that event
matches those that need frame events, send the event then.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
-rw-r--r-- | src/evdev.c | 57 |
1 files changed, 25 insertions, 32 deletions
diff --git a/src/evdev.c b/src/evdev.c index 200c2ef5..0a0655e9 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -628,16 +628,19 @@ fallback_flush_st_up(struct fallback_dispatch *dispatch, touch_notify_touch_up(base, time, -1, seat_slot); } -static void +static enum evdev_event_type fallback_flush_pending_event(struct fallback_dispatch *dispatch, struct evdev_device *device, uint64_t time) { + enum evdev_event_type sent_event; int slot_idx; + sent_event = dispatch->pending_event; + switch (dispatch->pending_event) { case EVDEV_NONE: - return; + break; case EVDEV_RELATIVE_MOTION: fallback_flush_relative_motion(dispatch, device, time); break; @@ -657,12 +660,14 @@ fallback_flush_pending_event(struct fallback_dispatch *dispatch, fallback_flush_st_down(dispatch, device, time); break; case EVDEV_ABSOLUTE_MOTION: - if (device->seat_caps & EVDEV_DEVICE_TOUCH) + if (device->seat_caps & EVDEV_DEVICE_TOUCH) { fallback_flush_st_motion(dispatch, device, time); - else if (device->seat_caps & EVDEV_DEVICE_POINTER) + sent_event = EVDEV_ABSOLUTE_MT_MOTION; + } else if (device->seat_caps & EVDEV_DEVICE_POINTER) { fallback_flush_absolute_motion(dispatch, device, time); + } break; case EVDEV_ABSOLUTE_TOUCH_UP: fallback_flush_st_up(dispatch, device, time); @@ -673,6 +678,8 @@ fallback_flush_pending_event(struct fallback_dispatch *dispatch, } dispatch->pending_event = EVDEV_NONE; + + return sent_event; } static enum evdev_key_type @@ -968,29 +975,6 @@ fallback_any_button_down(struct fallback_dispatch *dispatch, return false; } -static inline bool -fallback_need_touch_frame(struct fallback_dispatch *dispatch, - struct evdev_device *device) -{ - if (!(device->seat_caps & EVDEV_DEVICE_TOUCH)) - return false; - - switch (dispatch->pending_event) { - case EVDEV_NONE: - case EVDEV_RELATIVE_MOTION: - break; - case EVDEV_ABSOLUTE_MT_DOWN: - case EVDEV_ABSOLUTE_MT_MOTION: - case EVDEV_ABSOLUTE_MT_UP: - case EVDEV_ABSOLUTE_TOUCH_DOWN: - case EVDEV_ABSOLUTE_TOUCH_UP: - case EVDEV_ABSOLUTE_MOTION: - return true; - } - - return false; -} - static void evdev_tag_external_mouse(struct evdev_device *device, struct udev_device *udev_device) @@ -1039,7 +1023,7 @@ fallback_process(struct evdev_dispatch *evdev_dispatch, uint64_t time) { struct fallback_dispatch *dispatch = (struct fallback_dispatch*)evdev_dispatch; - bool need_frame = false; + enum evdev_event_type sent; switch (event->type) { case EV_REL: @@ -1052,11 +1036,20 @@ fallback_process(struct evdev_dispatch *evdev_dispatch, fallback_process_key(dispatch, device, event, time); break; case EV_SYN: - need_frame = fallback_need_touch_frame(dispatch, - device); - fallback_flush_pending_event(dispatch, device, time); - if (need_frame) + sent = fallback_flush_pending_event(dispatch, device, time); + switch (sent) { + case EVDEV_ABSOLUTE_TOUCH_DOWN: + case EVDEV_ABSOLUTE_TOUCH_UP: + case EVDEV_ABSOLUTE_MT_DOWN: + case EVDEV_ABSOLUTE_MT_MOTION: + case EVDEV_ABSOLUTE_MT_UP: touch_notify_frame(&device->base, time); + break; + case EVDEV_ABSOLUTE_MOTION: + case EVDEV_RELATIVE_MOTION: + case EVDEV_NONE: + break; + } break; } } |