diff --git a/frontend/device/kindle/device.lua b/frontend/device/kindle/device.lua index 1400dde56..7758c5f50 100644 --- a/frontend/device/kindle/device.lua +++ b/frontend/device/kindle/device.lua @@ -274,7 +274,7 @@ local touch_set = Set { "0F", "11", "10", "12" } local pw_set = Set { "24", "1B", "1D", "1F", "1C", "20" } local pw2_set = Set { "D4", "5A", "D5", "D6", "D7", "D8", "F2", "17", "60", "F4", "F9", "62", "61", "5F" } -local kt2_set = Set { "C6" } +local kt2_set = Set { "C6", "DD" } local kv_set = Set { "13", "54", "2A", "4F", "52", "53" } if k2_set[kindle_devcode] then diff --git a/frontend/ui/uimanager.lua b/frontend/ui/uimanager.lua index 98eed17bd..24f8670d2 100644 --- a/frontend/ui/uimanager.lua +++ b/frontend/ui/uimanager.lua @@ -51,6 +51,7 @@ local UIManager = { full_refresh_waveform_mode = WAVEFORM_MODE_GC16, partial_refresh_waveform_mode = WAVEFORM_MODE_GC16, wait_for_every_marker = false, + wait_for_ui_markers = false, -- force to repaint all the widget is stack, will be reset to false -- after each ui loop repaint_all = false, @@ -63,6 +64,8 @@ local UIManager = { -- trigger a full refresh when counter reaches FULL_REFRESH_COUNT FULL_REFRESH_COUNT = G_reader_settings:readSetting("full_refresh_count") or DRCOUNTMAX, refresh_count = 0, + -- only update specific regions of the screen + update_regions_func = nil, event_handlers = nil, @@ -129,6 +132,8 @@ function UIManager:init() -- Let the driver handle it on those models (asking for NTX_WFM_MODE_GL16 appears to be a very bad idea, #1146) self.partial_refresh_waveform_mode = WAVEFORM_MODE_AUTO self.wait_for_every_marker = false + -- NOTE: Let's see if a bit of waiting works around potential timing issues on Kobos when doing *UI* refreshes in fast succession. (Not a concern on Kindle, where we have MXCFB_WAIT_FOR_UPDATE_SUBMISSION). + self.wait_for_ui_markers = true end -- Let the driver decide what to do with PARTIAL UI updates... self.default_waveform_mode = WAVEFORM_MODE_AUTO @@ -390,6 +395,7 @@ function UIManager:repaint() widget.widget:paintTo(Screen.bb, widget.x, widget.y) if self._dirty[widget.widget] == "auto" then + -- Most likely a 'reader' refresh. 'request' in the sense once we hit our FULL_REFRESH_COUNT ;). request_full_refresh = true end if self._dirty[widget.widget] == "full" then @@ -426,8 +432,12 @@ function UIManager:repaint() local waveform_mode = self.default_waveform_mode local wait_for_marker = self.wait_for_every_marker if dirty then - if force_partial_refresh or force_fast_refresh then + if force_partial_refresh or force_fast_refresh or self.update_regions_func then refresh_type = UPDATE_MODE_PARTIAL + -- Override wait_for_marker if we need to enable the Kobo timing workaround on UI refreshes + if self.wait_for_ui_markers then + wait_for_marker = true + end elseif force_full_refresh or self.refresh_count == self.FULL_REFRESH_COUNT - 1 then refresh_type = UPDATE_MODE_FULL end @@ -467,11 +477,11 @@ function UIManager:repaint() -- REAGL refreshes are always FULL (but without a black flash), but we want to keep our black flash timeout working, so don't reset the counter on FULL REAGL refreshes... if refresh_type == UPDATE_MODE_FULL and waveform_mode ~= WAVEFORM_MODE_REAGL and waveform_mode ~= NTX_WFM_MODE_GLD16 then self.refresh_count = 0 - elseif not force_partial_refresh and not force_full_refresh then + elseif not force_partial_refresh and not force_full_refresh and not self.update_regions_func then self.refresh_count = (self.refresh_count + 1)%self.FULL_REFRESH_COUNT end - self.update_regions_func = nil end + self.update_regions_func = nil end -- this is the main loop of the UI controller diff --git a/frontend/ui/widget/button.lua b/frontend/ui/widget/button.lua index b954346d2..6a2c0169b 100644 --- a/frontend/ui/widget/button.lua +++ b/frontend/ui/widget/button.lua @@ -152,14 +152,14 @@ end function Button:onTapSelectButton() if self.enabled and self.callback then - self[1].invert = true - -- NOTE: Nope, this breaks the FM, by only refreshing the buttons themselves :D. - --[[ - UIManager.update_regions_func = function() - return {self[1].dimen} - end - --]] - UIManager:setDirty(self.show_parent, "partial") + UIManager:scheduleIn(0.0, function() + self[1].invert = true + UIManager.update_regions_func = function() + return {self[1].dimen} + end + UIManager.repaint_all = true -- FIXME: Why? + UIManager:setDirty(self.show_parent, "partial") + end) UIManager:scheduleIn(0.1, function() self.callback() self[1].invert = false diff --git a/frontend/ui/widget/iconbutton.lua b/frontend/ui/widget/iconbutton.lua index 808752b72..8871fccbf 100644 --- a/frontend/ui/widget/iconbutton.lua +++ b/frontend/ui/widget/iconbutton.lua @@ -39,11 +39,13 @@ function IconButton:initGesListener() end function IconButton:onTapClickButton() - self.image.invert = true - UIManager.update_regions_func = function() - return {self[1].dimen} - end - UIManager:setDirty(self.show_parent, "partial") + UIManager:scheduleIn(0.0, function() + self.image.invert = true + UIManager.update_regions_func = function() + return {self[1].dimen} + end + UIManager:setDirty(self.show_parent, "partial") + end) -- make sure button reacts before doing callback UIManager:scheduleIn(0.1, function() self.callback() diff --git a/frontend/ui/widget/touchmenu.lua b/frontend/ui/widget/touchmenu.lua index 6bc4a0728..53e85ac10 100644 --- a/frontend/ui/widget/touchmenu.lua +++ b/frontend/ui/widget/touchmenu.lua @@ -95,11 +95,13 @@ function TouchMenuItem:onTapSelect(arg, ges) end if enabled == false then return end - self.item_frame.invert = true - UIManager.update_regions_func = function() - return {self.dimen} - end - UIManager:setDirty(self.show_parent, "partial") + UIManager:scheduleIn(0.0, function() + self.item_frame.invert = true + UIManager.update_regions_func = function() + return {self.dimen} + end + UIManager:setDirty(self.show_parent, "partial") + end) UIManager:scheduleIn(0.1, function() self.menu:onMenuSelect(self.item) end) @@ -117,11 +119,13 @@ function TouchMenuItem:onHoldSelect(arg, ges) end if enabled == false then return end - self.item_frame.invert = true - UIManager.update_regions_func = function() - return {self.dimen} - end - UIManager:setDirty(self.show_parent, "partial") + UIManager:scheduleIn(0.0, function() + self.item_frame.invert = true + UIManager.update_regions_func = function() + return {self.dimen} + end + UIManager:setDirty(self.show_parent, "partial") + end) UIManager:scheduleIn(0.1, function() self.menu:onMenuHold(self.item) end) @@ -454,7 +458,7 @@ function TouchMenu:updateItems() self.page_info_right_chev:enableDisable(self.page < self.page_num) self.time_info.text = os.date("%H:%M").." @ "..Device:getPowerDevice():getCapacity().."%" -- FIXME: this is a dirty hack to clear previous menus - -- refert to issue #664 + -- refer to issue #664 (in kindlepdfviewer) UIManager.repaint_all = true end @@ -533,7 +537,7 @@ function TouchMenu:onMenuSelect(item) callback = item.callback_func() end if callback then - -- put stuff in scheduler so we can See + -- put stuff in scheduler so we can see -- the effect of inverted menu item UIManager:scheduleIn(0.1, function() self:closeMenu()