Random optimizations (#9657)

reviewable/pr9705/r1
zwim 2 years ago committed by GitHub
parent e72211a5bf
commit d7c63edca6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2072,5 +2072,4 @@ function ReaderHighlight:_createHighlightGesture(gesture)
} }
end end
return ReaderHighlight return ReaderHighlight

@ -318,17 +318,9 @@ function DeviceListener:onRestart()
self.ui.menu:exitOrRestart(function() UIManager:restartKOReader() end) self.ui.menu:exitOrRestart(function() UIManager:restartKOReader() end)
end end
function DeviceListener:onRequestSuspend() DeviceListener.onRequestSuspend = UIManager.suspend
UIManager:suspend() DeviceListener.onRequestReboot = UIManager.reboot
end DeviceListener.onRequestPowerOff = UIManager.powerOff
function DeviceListener:onRequestReboot()
UIManager:reboot()
end
function DeviceListener:onRequestPowerOff()
UIManager:powerOff()
end
function DeviceListener:onExit(callback) function DeviceListener:onExit(callback)
self.ui.menu:exitOrRestart(callback) self.ui.menu:exitOrRestart(callback)

@ -196,20 +196,22 @@ function UIManager:close(widget, refreshtype, refreshregion, refreshdither)
table.remove(self._window_stack, i) table.remove(self._window_stack, i)
dirty = true dirty = true
else else
-- If anything else on the stack not already hidden by (i.e., below) a fullscreen widget was dithered, honor the hint if not is_covered then
if w.dithered and not is_covered then -- If anything else on the stack not already hidden by (i.e., below) a fullscreen widget was dithered, honor the hint
refreshdither = true if w.dithered then
logger.dbg("Lower widget", w.name or w.id or tostring(w), "was dithered, honoring the dithering hint") refreshdither = true
end logger.dbg("Lower widget", w.name or w.id or tostring(w), "was dithered, honoring the dithering hint")
end
-- Remember the uppermost widget that covers the full screen, so we don't bother calling setDirty on hidden (i.e., lower) widgets in the following dirty loop. -- Remember the uppermost widget that covers the full screen, so we don't bother calling setDirty on hidden (i.e., lower) widgets in the following dirty loop.
-- _repaint already does that later on to skip the actual paintTo calls, so this ensures we limit the refresh queue to stuff that will actually get painted. -- _repaint already does that later on to skip the actual paintTo calls, so this ensures we limit the refresh queue to stuff that will actually get painted.
if not is_covered and w.covers_fullscreen then if w.covers_fullscreen then
is_covered = true is_covered = true
start_idx = i start_idx = i
logger.dbg("Lower widget", w.name or w.id or tostring(w), "covers the full screen") logger.dbg("Lower widget", w.name or w.id or tostring(w), "covers the full screen")
if i > 1 then if i > 1 then
logger.dbg("not refreshing", i-1, "covered widget(s)") logger.dbg("not refreshing", i-1, "covered widget(s)")
end
end end
end end
@ -677,10 +679,7 @@ function UIManager:getTopWidget()
end end
local widget = self._window_stack[#self._window_stack].widget local widget = self._window_stack[#self._window_stack].widget
if widget.name then return widget.name or widget
return widget.name
end
return widget
end end
--[[-- --[[--
@ -691,7 +690,7 @@ Useful when VirtualKeyboard is involved, as it *always* steals the top spot ;).
NOTE: Will skip over VirtualKeyboard instances, plural, in case there are multiple (because, apparently, we can do that.. ugh). NOTE: Will skip over VirtualKeyboard instances, plural, in case there are multiple (because, apparently, we can do that.. ugh).
--]] --]]
function UIManager:getSecondTopmostWidget() function UIManager:getSecondTopmostWidget()
if #self._window_stack <= 1 then if #self._window_stack < 2 then
-- Not enough widgets in the stack, bye! -- Not enough widgets in the stack, bye!
return nil return nil
end end
@ -748,16 +747,12 @@ function UIManager:quit(exit_code)
self._exit_code = exit_code or self._exit_code or 0 self._exit_code = exit_code or self._exit_code or 0
logger.info("quitting uimanager with exit code:", self._exit_code) logger.info("quitting uimanager with exit code:", self._exit_code)
self._task_queue_dirty = false self._task_queue_dirty = false
for i = #self._window_stack, 1, -1 do self._window_stack = {}
table.remove(self._window_stack, i) self._task_queue = {}
end
for i = #self._task_queue, 1, -1 do
table.remove(self._task_queue, i)
end
for i = #self._zeromqs, 1, -1 do for i = #self._zeromqs, 1, -1 do
self._zeromqs[i]:stop() self._zeromqs[i]:stop()
table.remove(self._zeromqs, i)
end end
self._zeromqs = {}
if self.looper then if self.looper then
self.looper:close() self.looper:close()
self.looper = nil self.looper = nil

Loading…
Cancel
Save