From 4e4df37f7b3738d3df1941b465580ddecbbedd2a Mon Sep 17 00:00:00 2001 From: chrox Date: Wed, 31 Jul 2013 16:55:50 +0800 Subject: [PATCH 1/6] fix fast refresh waveform --- frontend/ui/uimanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/ui/uimanager.lua b/frontend/ui/uimanager.lua index edb88423b..2874eb4b2 100644 --- a/frontend/ui/uimanager.lua +++ b/frontend/ui/uimanager.lua @@ -236,7 +236,7 @@ function UIManager:run() refresh_type = 0 end if force_fast_refresh then - self.waveform_mode = self.fast_waveform_mode + waveform_mode = self.fast_waveform_mode end if self.update_region_func then local update_region = self.update_region_func() From 19d70f27191569fce59fb6f6433ad339e99016a8 Mon Sep 17 00:00:00 2001 From: chrox Date: Wed, 31 Jul 2013 19:33:36 +0800 Subject: [PATCH 2/6] fix delChar decreasing charpos on blank charlist --- frontend/ui/widget/inputtext.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/ui/widget/inputtext.lua b/frontend/ui/widget/inputtext.lua index 7c347a74b..fe936f476 100644 --- a/frontend/ui/widget/inputtext.lua +++ b/frontend/ui/widget/inputtext.lua @@ -102,6 +102,7 @@ function InputText:addChar(char) end function InputText:delChar() + if self.charpos == 1 then return end self.charpos = self.charpos - 1 table.remove(self.charlist, self.charpos) self.text = self:CharlistToString() From fa9878301f4f678a41feea084c2af3336b3e6d69 Mon Sep 17 00:00:00 2001 From: chrox Date: Wed, 31 Jul 2013 19:35:47 +0800 Subject: [PATCH 3/6] 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() From 225ae9f826d91fb59019d34c3276534be7e8130c Mon Sep 17 00:00:00 2001 From: chrox Date: Wed, 31 Jul 2013 20:02:26 +0800 Subject: [PATCH 4/6] disable double tap detection in keyboard widget --- frontend/ui/uimanager.lua | 8 +++++++- frontend/ui/widget/keyboard.lua | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/ui/uimanager.lua b/frontend/ui/uimanager.lua index 2874eb4b2..a54560616 100644 --- a/frontend/ui/uimanager.lua +++ b/frontend/ui/uimanager.lua @@ -56,16 +56,22 @@ function UIManager:show(widget, x, y) self:setDirty(widget) -- tell the widget that it is shown now widget:handleEvent(Event:new("Show")) + -- check if this widget disables double tap gesture + if widget.disable_double_tap then + Input.disable_double_tap = true + end end -- unregister a widget function UIManager:close(widget) + Input.disable_double_tap = DGESDETECT_DISABLE_DOUBLE_TAP local dirty = false for i = #self._window_stack, 1, -1 do if self._window_stack[i].widget == widget then table.remove(self._window_stack, i) dirty = true - break + elseif self._window_stack[i].widget.disable_double_tap then + Input.disable_double_tap = true end end if dirty then diff --git a/frontend/ui/widget/keyboard.lua b/frontend/ui/widget/keyboard.lua index 472ca89aa..36a926237 100644 --- a/frontend/ui/widget/keyboard.lua +++ b/frontend/ui/widget/keyboard.lua @@ -109,6 +109,7 @@ end VirtualKeyboard = InputContainer:new{ is_always_active = true, + disable_double_tap = true, inputbox = nil, KEYS = {}, -- table to store layouts min_layout = 2, From fa21dfda63e113825c329a7ce7c6a5509c423bbf Mon Sep 17 00:00:00 2001 From: chrox Date: Wed, 31 Jul 2013 20:06:27 +0800 Subject: [PATCH 5/6] remove double_tap processing code in keyboard --- frontend/ui/widget/keyboard.lua | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/frontend/ui/widget/keyboard.lua b/frontend/ui/widget/keyboard.lua index 36a926237..39cad6e72 100644 --- a/frontend/ui/widget/keyboard.lua +++ b/frontend/ui/widget/keyboard.lua @@ -69,12 +69,6 @@ function VirtualKey:init() range = self.dimen, }, }, - DoubleTapSelect = { - GestureRange:new{ - ges = "double_tap", - range = self.dimen, - }, - }, } end end @@ -88,16 +82,6 @@ function VirtualKey:onTapSelect() return true end -function VirtualKey:onDoubleTapSelect() - self[1].invert = true - if self.callback then - self.callback() -- once - self.callback() -- twice - end - UIManager:scheduleIn(0.02, function() self:invert(false) end) - return true -end - function VirtualKey:invert(invert) self[1].invert = invert UIManager.update_region_func = function() From dea294d6b6b04bf448af2e0eeb139b9071aee341 Mon Sep 17 00:00:00 2001 From: chrox Date: Wed, 31 Jul 2013 20:37:34 +0800 Subject: [PATCH 6/6] update koreader-base --- koreader-base | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/koreader-base b/koreader-base index 30bf7abc3..214baabb9 160000 --- a/koreader-base +++ b/koreader-base @@ -1 +1 @@ -Subproject commit 30bf7abc31f144e6deba1b0ae4dadef9d7ac742e +Subproject commit 214baabb94680c3b7b17f3168463ac2868279f53