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>
This commit is contained in:
Peter Hutterer 2016-08-03 11:58:23 +10:00
parent b26d8f9122
commit b0ec4bacbd

View file

@ -628,16 +628,19 @@ fallback_flush_st_up(struct fallback_dispatch *dispatch,
touch_notify_touch_up(base, time, -1, seat_slot); touch_notify_touch_up(base, time, -1, seat_slot);
} }
static void static enum evdev_event_type
fallback_flush_pending_event(struct fallback_dispatch *dispatch, fallback_flush_pending_event(struct fallback_dispatch *dispatch,
struct evdev_device *device, struct evdev_device *device,
uint64_t time) uint64_t time)
{ {
enum evdev_event_type sent_event;
int slot_idx; int slot_idx;
sent_event = dispatch->pending_event;
switch (dispatch->pending_event) { switch (dispatch->pending_event) {
case EVDEV_NONE: case EVDEV_NONE:
return; break;
case EVDEV_RELATIVE_MOTION: case EVDEV_RELATIVE_MOTION:
fallback_flush_relative_motion(dispatch, device, time); fallback_flush_relative_motion(dispatch, device, time);
break; break;
@ -657,12 +660,14 @@ fallback_flush_pending_event(struct fallback_dispatch *dispatch,
fallback_flush_st_down(dispatch, device, time); fallback_flush_st_down(dispatch, device, time);
break; break;
case EVDEV_ABSOLUTE_MOTION: 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); 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, fallback_flush_absolute_motion(dispatch,
device, device,
time); time);
}
break; break;
case EVDEV_ABSOLUTE_TOUCH_UP: case EVDEV_ABSOLUTE_TOUCH_UP:
fallback_flush_st_up(dispatch, device, time); fallback_flush_st_up(dispatch, device, time);
@ -673,6 +678,8 @@ fallback_flush_pending_event(struct fallback_dispatch *dispatch,
} }
dispatch->pending_event = EVDEV_NONE; dispatch->pending_event = EVDEV_NONE;
return sent_event;
} }
static enum evdev_key_type static enum evdev_key_type
@ -968,29 +975,6 @@ fallback_any_button_down(struct fallback_dispatch *dispatch,
return false; 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 static void
evdev_tag_external_mouse(struct evdev_device *device, evdev_tag_external_mouse(struct evdev_device *device,
struct udev_device *udev_device) struct udev_device *udev_device)
@ -1039,7 +1023,7 @@ fallback_process(struct evdev_dispatch *evdev_dispatch,
uint64_t time) uint64_t time)
{ {
struct fallback_dispatch *dispatch = (struct fallback_dispatch*)evdev_dispatch; struct fallback_dispatch *dispatch = (struct fallback_dispatch*)evdev_dispatch;
bool need_frame = false; enum evdev_event_type sent;
switch (event->type) { switch (event->type) {
case EV_REL: case EV_REL:
@ -1052,11 +1036,20 @@ fallback_process(struct evdev_dispatch *evdev_dispatch,
fallback_process_key(dispatch, device, event, time); fallback_process_key(dispatch, device, event, time);
break; break;
case EV_SYN: case EV_SYN:
need_frame = fallback_need_touch_frame(dispatch, sent = fallback_flush_pending_event(dispatch, device, time);
device); switch (sent) {
fallback_flush_pending_event(dispatch, device, time); case EVDEV_ABSOLUTE_TOUCH_DOWN:
if (need_frame) 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); touch_notify_frame(&device->base, time);
break;
case EVDEV_ABSOLUTE_MOTION:
case EVDEV_RELATIVE_MOTION:
case EVDEV_NONE:
break;
}
break; break;
} }
} }