diff --git a/frontend/apps/reader/modules/readercropping.lua b/frontend/apps/reader/modules/readercropping.lua index 55404dc9f..a24174be5 100644 --- a/frontend/apps/reader/modules/readercropping.lua +++ b/frontend/apps/reader/modules/readercropping.lua @@ -148,7 +148,6 @@ function ReaderCropping:exitPageCrop(confirmed) else self:setCropZoomMode(confirmed) end - UIManager.repaint_all = true end function ReaderCropping:setCropZoomMode(confirmed) diff --git a/frontend/apps/reader/modules/readerfooter.lua b/frontend/apps/reader/modules/readerfooter.lua index 574baf19d..05b87ccb0 100644 --- a/frontend/apps/reader/modules/readerfooter.lua +++ b/frontend/apps/reader/modules/readerfooter.lua @@ -267,22 +267,19 @@ function ReaderFooter:onTapFooter(arg, ges) self.mode = 0 end self:applyFooterMode() - local region = Geom:new{ - x = 0, - y = Screen:getHeight() - self.height, - w = Screen:getWidth(), - h = self.height - } - UIManager.update_regions_func = function() - return {region} - end end if self.pageno then self:updateFooterPage() else self:updateFooterPos() end - UIManager:setDirty(self.view.dialog, "partial") + local region = Geom:new{ + x = 0, + y = Screen:getHeight() - self.height, + w = Screen:getWidth(), + h = self.height + } + UIManager:setDirty(self.view.dialog, "partial", region) G_reader_settings:saveSetting("reader_footer_mode", self.mode) return true end diff --git a/frontend/apps/reader/modules/readerhighlight.lua b/frontend/apps/reader/modules/readerhighlight.lua index 21d0f71e8..b642808c5 100644 --- a/frontend/apps/reader/modules/readerhighlight.lua +++ b/frontend/apps/reader/modules/readerhighlight.lua @@ -120,7 +120,6 @@ function ReaderHighlight:clear() else self.ui.document:clearSelection() end - UIManager:setDirty(self.dialog, "full") if self.hold_pos then self.hold_pos = nil self.selected_text = nil @@ -240,13 +239,9 @@ function ReaderHighlight:onHold(arg, ges) table.insert(boxes, self.selected_word.sbox) self.view.highlight.temp[self.hold_pos.page] = boxes end - --[[ - UIManager.update_regions_func = function() - DEBUG("update ReaderHighlight onHold region", self.selected_word.sbox) - return {self.selected_word.sbox} - end - --]] UIManager:setDirty(self.dialog, "partial") + -- TODO: only mark word? + -- UIManager:setDirty(self.dialog, "partial", self.selected_word.sbox) end return true end @@ -265,7 +260,12 @@ function ReaderHighlight:onHoldPan(arg, ges) self.holdpan_pos = self.view:screenToPageTransform(ges.pos) DEBUG("holdpan position in page", self.holdpan_pos) + local old_text = self.selected_text and self.selected_text.text self.selected_text = self.ui.document:getTextFromPositions(self.hold_pos, self.holdpan_pos) + if self.selected_text and old_text and old_text == self.selected_text.text then + -- no modification + return + end DEBUG("selected text:", self.selected_text) if self.selected_text then self.view.highlight.temp[self.hold_pos.page] = self.selected_text.sboxes diff --git a/frontend/apps/reader/modules/readerpaging.lua b/frontend/apps/reader/modules/readerpaging.lua index 6b43d8662..e9381f7ed 100644 --- a/frontend/apps/reader/modules/readerpaging.lua +++ b/frontend/apps/reader/modules/readerpaging.lua @@ -314,7 +314,8 @@ function ReaderPaging:onSwipe(arg, ges) self:onPagingRel(-1) end else - UIManager.full_refresh = true + -- trigger full refresh + UIManager:setDirty(nil, "full") end end @@ -343,7 +344,8 @@ function ReaderPaging:onPanRelease(arg, ges) end else self.last_pan_relative_y = 0 - UIManager.full_refresh = true + -- trigger full refresh + UIManager:setDirty(nil, "full") end end @@ -649,7 +651,7 @@ function ReaderPaging:onScrollPageRel(diff) end -- update current pageno to the very last part in current view self:gotoPage(self.view.page_states[#self.view.page_states].page, "scrolling") - UIManager:setDirty(self.view.dialog) + UIManager:setDirty(self.view.dialog, "partial") end function ReaderPaging:onGotoPageRel(diff) diff --git a/frontend/apps/reader/modules/readerrolling.lua b/frontend/apps/reader/modules/readerrolling.lua index 25ad6b4a8..83b4effad 100644 --- a/frontend/apps/reader/modules/readerrolling.lua +++ b/frontend/apps/reader/modules/readerrolling.lua @@ -389,7 +389,7 @@ function ReaderRolling:updatePos() self.old_page = new_page self.ui:handleEvent(Event:new("UpdateToc")) end - UIManager.repaint_all = true + UIManager:setDirty(self.view.dialog, "partial") end --[[ diff --git a/frontend/apps/reader/modules/readerscreenshot.lua b/frontend/apps/reader/modules/readerscreenshot.lua index b500f4446..346adf2b6 100644 --- a/frontend/apps/reader/modules/readerscreenshot.lua +++ b/frontend/apps/reader/modules/readerscreenshot.lua @@ -42,7 +42,8 @@ function ReaderScreenshot:onScreenshot(filename) timeout = 2, }) Screen:shot(screenshot_name) - UIManager.full_refresh = true + -- trigger full refresh + UIManager:setDirty(nil, "full") return true end diff --git a/frontend/apps/reader/modules/readersearch.lua b/frontend/apps/reader/modules/readersearch.lua index 8851d0156..a21aba836 100644 --- a/frontend/apps/reader/modules/readersearch.lua +++ b/frontend/apps/reader/modules/readersearch.lua @@ -71,6 +71,7 @@ function ReaderSearch:onShowSearchDialog(text) } local res = do_search(self.searchFromCurrent, text, 0)() UIManager:show(self.search_dialog) + -- TODO: regional UIManager:setDirty(self.dialog, "partial") return true end diff --git a/frontend/apps/reader/modules/readerview.lua b/frontend/apps/reader/modules/readerview.lua index e9f7c0273..d765fc27b 100644 --- a/frontend/apps/reader/modules/readerview.lua +++ b/frontend/apps/reader/modules/readerview.lua @@ -508,7 +508,7 @@ function ReaderView:recalculate() self.state.offset.x = (self.dimen.w - self.visible_area.w) / 2 end -- flag a repaint so self:paintTo will be called - UIManager:setDirty(self.dialog) + UIManager:setDirty(self.dialog, "partial") end function ReaderView:PanningUpdate(dx, dy) @@ -517,7 +517,7 @@ function ReaderView:PanningUpdate(dx, dy) self.visible_area:offsetWithin(self.page_area, dx, dy) if self.visible_area ~= old then -- flag a repaint - UIManager:setDirty(self.dialog) + UIManager:setDirty(self.dialog, "partial") DEBUG("on pan: page_area", self.page_area) DEBUG("on pan: visible_area", self.visible_area) self.ui:handleEvent( @@ -534,7 +534,7 @@ function ReaderView:PanningStart(x, y) self.visible_area = self.panning_visible_area:copy() self.visible_area:offsetWithin(self.page_area, x, y) self.ui:handleEvent(Event:new("ViewRecalculate", self.visible_area, self.page_area)) - UIManager:setDirty(self.dialog) + UIManager:setDirty(self.dialog, "partial") end function ReaderView:PanningStop() @@ -546,7 +546,7 @@ function ReaderView:SetZoomCenter(x, y) self.visible_area:centerWithin(self.page_area, x, y) if self.visible_area ~= old then self.ui:handleEvent(Event:new("ViewRecalculate", self.visible_area, self.page_area)) - UIManager:setDirty(self.dialog) + UIManager:setDirty(self.dialog, "partial") end end diff --git a/frontend/ui/widget/bboxwidget.lua b/frontend/ui/widget/bboxwidget.lua index ff108f47d..8c1a98ef2 100644 --- a/frontend/ui/widget/bboxwidget.lua +++ b/frontend/ui/widget/bboxwidget.lua @@ -190,7 +190,7 @@ function BBoxWidget:adjustScreenBBox(ges, relative) y1 = Math.round(bottom_right.y) } - UIManager.repaint_all = true + UIManager:setDirty("all") end function BBoxWidget:getModifiedPageBBox() diff --git a/frontend/ui/widget/button.lua b/frontend/ui/widget/button.lua index 6a2c0169b..bc35839bf 100644 --- a/frontend/ui/widget/button.lua +++ b/frontend/ui/widget/button.lua @@ -154,16 +154,16 @@ function Button:onTapSelectButton() if self.enabled and self.callback then 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") + UIManager:setDirty(self.show_parent, function() + return "partial", self[1].dimen + end) end) UIManager:scheduleIn(0.1, function() self.callback() self[1].invert = false - UIManager:setDirty(self.show_parent, "partial") + UIManager:setDirty(self.show_parent, function() + return "partial", self[1].dimen + end) end) end return true diff --git a/frontend/ui/widget/configdialog.lua b/frontend/ui/widget/configdialog.lua index c34e17d40..fc9d10b2a 100644 --- a/frontend/ui/widget/configdialog.lua +++ b/frontend/ui/widget/configdialog.lua @@ -70,10 +70,9 @@ function OptionTextItem:onTapSelect() self.config:onConfigChoose(self.values, self.name, self.event, self.args, self.events, self.current_item) - UIManager.update_regions_func = function() - return {self[1].dimen} - end - UIManager:setDirty(self.config, "partial") + UIManager:setDirty(self.config, function() + return "partial", self[1].dimen + end) return true end @@ -125,10 +124,9 @@ function OptionIconItem:onTapSelect() self.config:onConfigChoose(self.values, self.name, self.event, self.args, self.events, self.current_item) - UIManager.update_regions_func = function() - return {self[1].dimen} - end - UIManager:setDirty(self.config, "partial") + UIManager:setDirty(self.config, function() + return "partial", self[1].dimen + end) return true end @@ -525,7 +523,7 @@ end function ConfigDialog:onShowConfigPanel(index) self.panel_index = index self:update() - UIManager.repaint_all = true + UIManager:setDirty("all") return true end @@ -563,7 +561,7 @@ function ConfigDialog:onConfigChoose(values, name, event, args, events, position if events then self:onConfigEvents(events, position) end - UIManager.repaint_all = true + UIManager:setDirty("all") end) end diff --git a/frontend/ui/widget/dictquicklookup.lua b/frontend/ui/widget/dictquicklookup.lua index 000f4d292..5c11dd4ad 100644 --- a/frontend/ui/widget/dictquicklookup.lua +++ b/frontend/ui/widget/dictquicklookup.lua @@ -256,8 +256,7 @@ function DictQuickLookup:update() self.dict_frame, } } - UIManager.repaint_all = true - UIManager.partial_refresh = true + UIManager:setDirty("all", "partial") end function DictQuickLookup:isPrevDictAvaiable() diff --git a/frontend/ui/widget/focusmanager.lua b/frontend/ui/widget/focusmanager.lua index df70cdd78..a88200119 100644 --- a/frontend/ui/widget/focusmanager.lua +++ b/frontend/ui/widget/focusmanager.lua @@ -80,6 +80,7 @@ function FocusManager:onFocusMove(args) current_item:handleEvent(Event:new("Unfocus")) self.layout[self.selected.y][self.selected.x]:handleEvent(Event:new("Focus")) -- trigger a repaint (we need to be the registered widget!) + -- TODO: is this really needed? UIManager:setDirty(self.show_parent or self, "partial") break end diff --git a/frontend/ui/widget/iconbutton.lua b/frontend/ui/widget/iconbutton.lua index 5ac13f63e..f67afb267 100644 --- a/frontend/ui/widget/iconbutton.lua +++ b/frontend/ui/widget/iconbutton.lua @@ -43,16 +43,17 @@ end function IconButton:onTapClickButton() 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") + UIManager:setDirty(self.show_parent, function() + return "partial", self[1].dimen + end) end) -- make sure button reacts before doing callback UIManager:scheduleIn(0.1, function() self.callback() self.image.invert = false - UIManager:setDirty(self.show_parent, "partial") + UIManager:setDirty(self.show_parent, function() + return "partial", self[1].dimen + end) end) return true end diff --git a/frontend/ui/widget/inputdialog.lua b/frontend/ui/widget/inputdialog.lua index 9b10e6517..a36d27470 100644 --- a/frontend/ui/widget/inputdialog.lua +++ b/frontend/ui/widget/inputdialog.lua @@ -116,8 +116,8 @@ function InputDialog:init() }, self.dialog_frame, } - UIManager.repaint_all = true - UIManager.full_refresh = true + -- do a full refresh - is this really needed? + UIManager:setDirty("all", "full") end function InputDialog:onShowKeyboard() diff --git a/frontend/ui/widget/inputtext.lua b/frontend/ui/widget/inputtext.lua index ae7b6bc96..fc342317f 100644 --- a/frontend/ui/widget/inputtext.lua +++ b/frontend/ui/widget/inputtext.lua @@ -154,7 +154,9 @@ function InputText:addChar(char) table.insert(self.charlist, self.charpos, char) self.charpos = self.charpos + 1 self:initTextBox(table.concat(self.charlist)) - UIManager:setDirty(self.parent, "partial") + UIManager:setDirty(self.parent, function() + return "ui", self.dimen + end) end function InputText:delChar() @@ -162,12 +164,14 @@ function InputText:delChar() self.charpos = self.charpos - 1 table.remove(self.charlist, self.charpos) self:initTextBox(table.concat(self.charlist)) - UIManager:setDirty(self.parent, "partial") + UIManager:setDirty(self.parent, "ui") end function InputText:clear() self:initTextBox("") - UIManager:setDirty(self.parent, "partial") + UIManager:setDirty(self.parent, function() + return "ui", self.dimen + end) end function InputText:getText() @@ -176,7 +180,9 @@ end function InputText:setText(text) self:initTextBox(text) - UIManager:setDirty(self.parent, "partial") + UIManager:setDirty(self.parent, function() + return "partial", self.dimen + end) end return InputText diff --git a/frontend/ui/widget/logindialog.lua b/frontend/ui/widget/logindialog.lua index 1b147be66..006a1f5f4 100644 --- a/frontend/ui/widget/logindialog.lua +++ b/frontend/ui/widget/logindialog.lua @@ -87,8 +87,7 @@ function LoginDialog:init() }, self.dialog_frame, } - UIManager.repaint_all = true - UIManager.full_refresh = true + UIManager:setDirty("all", "full") end function LoginDialog:getCredential() diff --git a/frontend/ui/widget/menu.lua b/frontend/ui/widget/menu.lua index 3b7cdfbe6..fa1cd9599 100644 --- a/frontend/ui/widget/menu.lua +++ b/frontend/ui/widget/menu.lua @@ -283,6 +283,7 @@ end function MenuItem:onTapSelect(arg, ges) local pos = self:getGesPosition(ges) self[1].invert = true + -- TODO: regional refresh UIManager:setDirty(self.show_parent, "partial") UIManager:scheduleIn(0.1, function() self[1].invert = false @@ -295,6 +296,7 @@ end function MenuItem:onHoldSelect(arg, ges) local pos = self:getGesPosition(ges) self[1].invert = true + -- TODO: regional refresh UIManager:setDirty(self.show_parent, "partial") UIManager:scheduleIn(0.1, function() self[1].invert = false @@ -650,7 +652,9 @@ function Menu:updateItems(select_number) -- nicolua -- FIXME: dirty hack to clear previous menus - UIManager:setDirty(self.show_parent or self) + -- TODO: regional refresh + UIManager:setDirty("all", "partial") + --UIManager:setDirty(self.show_parent or self, "partial") end --[[ diff --git a/frontend/ui/widget/multiinputdialog.lua b/frontend/ui/widget/multiinputdialog.lua index 572c0f484..96a46d9e3 100644 --- a/frontend/ui/widget/multiinputdialog.lua +++ b/frontend/ui/widget/multiinputdialog.lua @@ -79,8 +79,7 @@ function MultiInputDialog:init() }, self.dialog_frame, } - UIManager.repaint_all = true - UIManager.full_refresh = true + UIManager:setDirty("all", "full") end function MultiInputDialog:getFields() diff --git a/frontend/ui/widget/scrolltextwidget.lua b/frontend/ui/widget/scrolltextwidget.lua index fdc8b90df..28a86ee00 100644 --- a/frontend/ui/widget/scrolltextwidget.lua +++ b/frontend/ui/widget/scrolltextwidget.lua @@ -77,10 +77,9 @@ function ScrollTextWidget:onScrollText(arg, ges) self.text_widget:scrollUp() self:updateScrollBar(self.text_widget) end - UIManager.update_regions_func = function() - return {self.dimen} - end - UIManager:setDirty(self.dialog, "partial") + UIManager:setDirty(self.dialog, function() + return "partial", self.dimen + end) end return ScrollTextWidget diff --git a/frontend/ui/widget/toggleswitch.lua b/frontend/ui/widget/toggleswitch.lua index ee6004d82..b63a74702 100644 --- a/frontend/ui/widget/toggleswitch.lua +++ b/frontend/ui/widget/toggleswitch.lua @@ -144,10 +144,9 @@ function ToggleSwitch:onTapSelect(arg, gev) --]] self.config:onConfigChoose(self.values, self.name, self.event, self.args, self.events, self.position) - UIManager.update_regions_func = function() - return {self.dimen} - end - UIManager:setDirty(self.config, "partial") + UIManager:setDirty(self.config, function() + return "partial", self.dimen + end) return true end diff --git a/frontend/ui/widget/touchmenu.lua b/frontend/ui/widget/touchmenu.lua index 37fe8af2f..7a75eece7 100644 --- a/frontend/ui/widget/touchmenu.lua +++ b/frontend/ui/widget/touchmenu.lua @@ -98,17 +98,18 @@ function TouchMenuItem:onTapSelect(arg, ges) 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") + UIManager:setDirty(self.show_parent, function() + return "partial", self.dimen + end) end) UIManager:scheduleIn(0.1, function() self.menu:onMenuSelect(self.item) end) UIManager:scheduleIn(0.5, function() self.item_frame.invert = false - UIManager:setDirty(self.show_parent, "partial") + UIManager:setDirty(self.show_parent, function() + return "partial", self.dimen + end) end) return true end @@ -122,17 +123,18 @@ function TouchMenuItem:onHoldSelect(arg, ges) 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") + UIManager:setDirty(self.show_parent, function() + return "partial", self.dimen + end) end) UIManager:scheduleIn(0.1, function() self.menu:onMenuHold(self.item) end) UIManager:scheduleIn(0.5, function() self.item_frame.invert = false - UIManager:setDirty(self.show_parent, "partial") + UIManager:setDirty(self.show_parent, function() + return "partial", self.dimen + end) end) return true end @@ -460,7 +462,9 @@ function TouchMenu:updateItems() self.time_info.text = os.date("%H:%M").." @ "..Device:getPowerDevice():getCapacity().."%" -- FIXME: this is a dirty hack to clear previous menus -- refer to issue #664 (in kindlepdfviewer) - UIManager.repaint_all = true + -- TODO: regional refresh + UIManager:setDirty("all", "partial") + --UIManager:setDirty(self.show_parent or self, "partial") end function TouchMenu:switchMenuTab(tab_num) diff --git a/frontend/ui/widget/virtualkeyboard.lua b/frontend/ui/widget/virtualkeyboard.lua index b0a8fe6b8..1cc861c4c 100644 --- a/frontend/ui/widget/virtualkeyboard.lua +++ b/frontend/ui/widget/virtualkeyboard.lua @@ -96,21 +96,22 @@ function VirtualKey:init() end function VirtualKey:update_keyboard() - UIManager.update_regions_func = function() + UIManager:setDirty(self.keyboard, function() DEBUG("update key region", self[1].dimen) - return {self[1].dimen} - end - UIManager:setDirty(self.keyboard, "partial") + return "ui", self[1].dimen + end) end function VirtualKey:update_keyboard_inputbox() local inputbox = self.keyboard.inputbox - UIManager.update_regions_func = function() - DEBUG("update keyboard and inputbox", self[1].dimen, inputbox.dimen) - return {self[1].dimen, inputbox.dimen} - end - UIManager:setDirty(inputbox, "partial") - UIManager:setDirty(self.keyboard, "partial") + UIManager:setDirty(self.keyboard, function() + DEBUG("update inputbox", inputbox.dimen) + return "ui", inputbox.dimen + end) + UIManager:setDirty(self.keyboard, function() + DEBUG("update keyboard", self[1].dimen) + return "ui", self[1].dimen + end) end function VirtualKey:onTapSelect() @@ -318,8 +319,13 @@ function VirtualKeyboard:setLayout(key) if self.utf8mode then self.umlautmode = false end end self:initLayout() - UIManager.update_regions_func = nil - UIManager:setDirty(self, "partial") + UIManager:setDirty(self, function() + -- correct coordinates of keyboard + local dimen = self.dimen:copy() + dimen.y = Screen:getHeight() - dimen.h + DEBUG("update keyboard layout", dimen) + return "partial", dimen + end) end function VirtualKeyboard:addChar(key) diff --git a/frontend/up_reg.list b/frontend/up_reg.list new file mode 100644 index 000000000..77fddaf52 --- /dev/null +++ b/frontend/up_reg.list @@ -0,0 +1,19 @@ +./apps/reader/modules/readerfooter.lua: UIManager.update_regions_func = function() +./apps/reader/modules/readerhighlight.lua: UIManager.update_regions_func = function() +./ui/widget/button.lua: UIManager.update_regions_func = function() +./ui/widget/iconbutton.lua: UIManager.update_regions_func = function() +./ui/widget/dictquicklookup.lua: UIManager.update_regions_func = function() +./ui/widget/scrolltextwidget.lua: UIManager.update_regions_func = function() +./ui/widget/touchmenu.lua: UIManager.update_regions_func = function() +./ui/widget/touchmenu.lua: UIManager.update_regions_func = function() +./ui/widget/virtualkeyboard.lua: UIManager.update_regions_func = function() +./ui/widget/virtualkeyboard.lua: UIManager.update_regions_func = function() +./ui/widget/virtualkeyboard.lua: UIManager.update_regions_func = nil +./ui/widget/toggleswitch.lua: UIManager.update_regions_func = function() +./ui/widget/configdialog.lua: UIManager.update_regions_func = function() +./ui/widget/configdialog.lua: UIManager.update_regions_func = function() +./ui/uimanager.lua: update_regions_func = nil, +./ui/uimanager.lua: if self.update_regions_func then +./ui/uimanager.lua: local update_regions = self.update_regions_func() +./ui/uimanager.lua: for _, update_region in ipairs(update_regions) do +./ui/uimanager.lua: self.update_regions_func = nil