Hilariously simpler fix for #6616 (#6650)

* Hilariously simpler fix for #6616

Reverts #6648 for a much, much simpler solution, that will actually
cover every possible situation automagically.
reviewable/pr6652/r1
NiLuJe 4 years ago committed by GitHub
parent e0546d0fc8
commit 592e4f42df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -81,7 +81,6 @@ end
function ReaderConfig:onShowConfigMenu()
self.config_dialog = ConfigDialog:new{
covers_footer = true, -- hint for UIManager:repaintReaderFooter
dimen = self.dimen:copy(),
document = self.document,
ui = self.ui,

@ -19,6 +19,7 @@ local UIManager = require("ui/uimanager")
local VerticalGroup = require("ui/widget/verticalgroup")
local VerticalSpan = require("ui/widget/verticalspan")
local WidgetContainer = require("ui/widget/container/widgetcontainer")
local logger = require("logger")
local util = require("util")
local T = require("ffi/util").template
local _ = require("gettext")
@ -561,7 +562,14 @@ end
function ReaderFooter:setupAutoRefreshTime()
if not self.autoRefreshTime then
self.autoRefreshTime = function()
self:onUpdateFooter(true)
-- Only actually repaint the footer if nothing's being shown over ReaderUI (#6616)
if UIManager:getTopWidget() == "ReaderUI" then
self:onUpdateFooter(true)
else
logger.dbg("Skipping ReaderFooter repaint, because ReaderUI is not the top-level widget")
-- NOTE: We *do* keep its content up-to-date, though
self:onUpdateFooter()
end
UIManager:scheduleIn(61 - tonumber(os.date("%S")), self.autoRefreshTime)
end
end
@ -1795,13 +1803,11 @@ function ReaderFooter:_updateFooterText(force_repaint, force_recompute)
-- Unfortunately, it's not a modal (we never show() it), so it's not in the window stack,
-- instead, it's baked inside ReaderUI, so it gets slightly trickier...
-- NOTE: self.view.footer -> self ;).
if UIManager:repaintReaderFooter(self.view.footer) then
-- NOTE: repaintReaderFooter will sometimes choose *not* to repaint, in which case,
-- we don't want to generate a bogus setDirty call ;).
UIManager:setDirty(self.view.footer, function()
return "ui", refresh_dim
end)
end
UIManager:setDirty(self.view.footer, function()
return "ui", refresh_dim
end)
-- c.f., ReaderView:paintTo()
UIManager:widgetRepaint(self.view.footer, 0, 0)
else
UIManager:setDirty(self.view.dialog, function()
return "ui", refresh_dim
@ -2007,16 +2013,6 @@ function ReaderFooter:onSuspend()
end
end
-- We want to be able to disable auto_refresh_time when displaying *some* non-fullscreen widgets on top of ReaderUI,
-- otherwise it'll happily keep on ticking and drawing on top of stuff it ought not to... (#6616)
--- @note: If the widget actually makes it to UIManager's window stack (i.e., it's passed to UIManager:show()),
--- it's generally simpler to set covers_footer when initializing the Widget object.
-- Since these Events are not currently in use, comment the handlers out ;).
--[[
ReaderFooter.onDisableFooterAutoRefresh = ReaderFooter.onSuspend
ReaderFooter.onRestoreFooterAutoRefresh = ReaderFooter.onResume
--]]
function ReaderFooter:onFrontlightStateChanged()
if self.settings.frontlight then
self:onUpdateFooter(true)

@ -1263,7 +1263,6 @@ function ReaderLink:showAsFootnotePopup(link, neglect_current_location)
local FootnoteWidget = require("ui/widget/footnotewidget")
local popup
popup = FootnoteWidget:new{
covers_footer = true, -- hint for UIManager:repaintReaderFooter
html = html,
doc_font_size = Screen:scaleBySize(self.ui.font.font_size),
doc_margins = self.ui.document:getPageMargins(),

@ -1151,43 +1151,6 @@ function UIManager:widgetRepaint(widget, x, y)
widget:paintTo(Screen.bb, x, y)
end
-- Now, this one is basically widgetRepaint, but tailored for a very,
-- very specific use-case related to ReaderFooter:setupAutoRefreshTime
-- (c.f., #6648)
function UIManager:repaintReaderFooter(readerfooter_widget)
if not readerfooter_widget then return false end
-- Don't repaint if there's another widget than ReaderUI flagged as covers_fullscreen being shown,
-- or if a non-fullscreen widget is flagged as covers_footer.
-- This isn't particularly pretty, but, oh, well (#6616).
local skip_repaint = false
-- c.f., UIManager:_repaint
for i = #self._window_stack, 1, -1 do
local widget = self._window_stack[i].widget
if widget.covers_fullscreen then
if widget.name and widget.name == "ReaderUI" then -- luacheck: ignore
-- NOP (i.e., continue)
else
skip_repaint = true
logger.dbg("Skipping ReaderFooter repaint, because something covers ReaderUI")
break
end
elseif widget.covers_footer then
skip_repaint = true
logger.dbg("Skipping ReaderFooter repaint, because something covers ReaderFooter")
break
end
end
if skip_repaint then return false end
logger.dbg("Explicit ReaderFooter repaint:", readerfooter_widget.name or readerfooter_widget.id or tostring(readerfooter_widget))
-- c.f., ReaderView:paintTo()
readerfooter_widget:paintTo(Screen.bb, 0, 0)
-- Inform the caller that we did, in fact, repaint it.
return true
end
function UIManager:setInputTimeout(timeout)
self.INPUT_TIMEOUT = timeout or 200*1000
end

@ -37,7 +37,7 @@ function AutoTurn:_schedule(settings_id)
local delay = self.last_action_sec + self.autoturn_sec - os.time()
if delay <= 0 then
if UIManager:getTopWidget() == "ReaderUI"then
if UIManager:getTopWidget() == "ReaderUI" then
logger.dbg("AutoTurn: go to next page")
self.ui:handleEvent(Event:new("GotoViewRel", self.autoturn_distance))
end

Loading…
Cancel
Save