From 3768aa0b56bc6558c05774af3157936e32aa7408 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Thu, 11 Aug 2022 17:56:40 +0200 Subject: [PATCH] GestureDetector: Clear *all* pending hold states on hold_release. We'll only honor one (the last one) anyway, and we've already cleared the timers, so the others are essentially lost and stuck in limbo. (Repro: do a series of staggered holds on different words with different fingers in a CRe document; the one that'll "take" is the last one, but *every* slot will be stuck in a hold state, which can essentially semi lock you into broken input until you manage to clear the right slots by doing duplicate multi-slot holds again...). --- frontend/device/gesturedetector.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/device/gesturedetector.lua b/frontend/device/gesturedetector.lua index 25e51d792..1d54fae45 100644 --- a/frontend/device/gesturedetector.lua +++ b/frontend/device/gesturedetector.lua @@ -395,8 +395,8 @@ function GestureDetector:tapState(tev) self:probeClockSource(tev.timev) end - logger.dbg("in tap state...") local slot = tev.slot + logger.dbg("slot", slot, "in tap state...") if tev.id == -1 then local s1 = self.input.main_finger_slot local s2 = self.input.main_finger_slot + 1 @@ -563,8 +563,8 @@ function GestureDetector:handleNonTap(tev) end function GestureDetector:panState(tev) - logger.dbg("in pan state...") local slot = tev.slot + logger.dbg("slot", slot, "in pan state...") if tev.id == -1 then -- end of pan, signal swipe gesture if necessary if self:isSwipe(slot) then @@ -816,8 +816,8 @@ function GestureDetector:handlePanRelease(tev) end function GestureDetector:holdState(tev, hold) - logger.dbg("in hold state...") local slot = tev.slot + logger.dbg("slot", slot, "in hold state...") -- When we switch to hold state, we pass an additional boolean param "hold". if tev.id ~= -1 and hold and self.last_tevs[slot].x and self.last_tevs[slot].y then self.states[slot] = self.holdState @@ -835,7 +835,8 @@ function GestureDetector:holdState(tev, hold) logger.dbg("hold_release detected in slot", slot) local last_x = self.last_tevs[slot].x local last_y = self.last_tevs[slot].y - self:clearState(slot) + -- NOTE: Don't leave multiple slots "stuck" in hold state, as we've cleared their timeouts in the main input loop anyway. + self:clearStates() return { ges = "hold_release", pos = Geom:new{