From fa9878301f4f678a41feea084c2af3336b3e6d69 Mon Sep 17 00:00:00 2001 From: chrox Date: Wed, 31 Jul 2013 19:35:47 +0800 Subject: [PATCH] disable double tap detection by default in gesture detector since the gesture detector will block the main thread (the only thread in the lua part) for 300 ms on each tap waiting for the arrival of the second tap, it makes the whole application less responsive. 300 ms of latency is well perceived in this case. This patch will simply disable double tap detection by default as no widget now handles double_tap gestures. We could temporarily enable double tap detection when this gesture is indeed needed after. --- defaults.lua | 2 ++ frontend/ui/gesturedetector.lua | 3 ++- frontend/ui/inputevent.lua | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/defaults.lua b/defaults.lua index 4e19dd417..1eefe2292 100644 --- a/defaults.lua +++ b/defaults.lua @@ -48,6 +48,8 @@ DKOPTREADER_CONFIG_DOC_LANGS_TEXT = {"English", "Chinese_S", "Chinese_T"} DKOPTREADER_CONFIG_DOC_LANGS_CODE = {"eng", "chi_sim", "chi_tra"} -- ISO 639-3 language string, DKOPTREADER_CONFIG_DOC_DEFAULT_LANG_CODE = "eng" -- and make sure you have corresponding training data +-- gesture detector defaults +DGESDETECT_DISABLE_DOUBLE_TAP = true -- #################################################################### -- following features are not supported right now diff --git a/frontend/ui/gesturedetector.lua b/frontend/ui/gesturedetector.lua index a84aa5181..2ed90be7d 100644 --- a/frontend/ui/gesturedetector.lua +++ b/frontend/ui/gesturedetector.lua @@ -350,7 +350,8 @@ function GestureDetector:handleDoubleTap(tev) DEBUG("set up tap timer") -- deadline should be calculated by adding current tap time and the interval local deadline = cur_tap.timev + TimeVal:new{ - sec = 0, usec = self.DOUBLE_TAP_INTERVAL, + sec = 0, + usec = not Input.disable_double_tap and self.DOUBLE_TAP_INTERVAL or 0, } Input:setTimeout(function() DEBUG("in tap timer", self.last_taps[slot] ~= nil) diff --git a/frontend/ui/inputevent.lua b/frontend/ui/inputevent.lua index 186a81145..8a28b6ab3 100644 --- a/frontend/ui/inputevent.lua +++ b/frontend/ui/inputevent.lua @@ -136,6 +136,7 @@ Input = { }, rotation = 0, timer_callbacks = {}, + disable_double_tap = DGESDETECT_DISABLE_DOUBLE_TAP, } function Input:initKeyMap()