From da0a630f141c1d8eb6fea70c172e99d8b3f48467 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 13 Jul 2018 15:41:59 +1000 Subject: [PATCH] fallback: change a list of if conditions to a switch statement This used to do a lot more but now it can be handled as simple switch statement. Bonus: we get to log a bug if we ever get here in NONE state. Signed-off-by: Peter Hutterer --- src/evdev-fallback.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/evdev-fallback.c b/src/evdev-fallback.c index 55c585e..292f98b 100644 --- a/src/evdev-fallback.c +++ b/src/evdev-fallback.c @@ -825,23 +825,32 @@ fallback_handle_state(struct fallback_dispatch *dispatch, if (!slot->dirty) continue; - if (slot->state == SLOT_STATE_BEGIN) { + switch (slot->state) { + case SLOT_STATE_BEGIN: sent = fallback_flush_mt_down(dispatch, device, i, time); slot->state = SLOT_STATE_UPDATE; - } else if (slot->state == SLOT_STATE_UPDATE) { + break; + case SLOT_STATE_UPDATE: sent = fallback_flush_mt_motion(dispatch, device, i, time); - } else if (slot->state == SLOT_STATE_END) { + break; + case SLOT_STATE_END: sent = fallback_flush_mt_up(dispatch, device, i, time); slot->state = SLOT_STATE_NONE; + break; + case SLOT_STATE_NONE: + /* touch arbitration may swallow the begin, + * so we may get updates for a touch still + * in NONE state */ + break; } slot->dirty = false; -- 2.7.4