From 2e681353d7d0997d478460254ece5a81ddfee9c6 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sat, 11 Jun 2022 19:40:10 +0200 Subject: [PATCH] UIManager: Simplify setPMInputTimeout (from #9173) This was originally designed for finer-grainbed control (specifically, to correct by the amount of time spent in standby), but the final fix only ever sets this to 0. Simplify and rename (consumeInputEarlyAfterPM) to avoid useless computations. --- frontend/ui/uimanager.lua | 12 ++++++------ plugins/autosuspend.koplugin/main.lua | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/frontend/ui/uimanager.lua b/frontend/ui/uimanager.lua index a7953cded..6a9854cd2 100644 --- a/frontend/ui/uimanager.lua +++ b/frontend/ui/uimanager.lua @@ -1659,11 +1659,11 @@ function UIManager:handleInput() -- this function emits (plugin), or within waitEvent() right after (hardware). -- Anywhere else breaks preventStandby/allowStandby invariants used by background jobs while UI is left running. self:_standbyTransition() - if self.PM_INPUT_TIMEOUT then + if self._pm_consume_input_early then -- If the PM state transition requires an early return from input polling, honor that. -- c.f., UIManager:setPMInputTimeout (and AutoSuspend:AllowStandbyHandler). - deadline = now + time.s(self.PM_INPUT_TIMEOUT) - self.PM_INPUT_TIMEOUT = nil + deadline = now + self._pm_consume_input_early = false end -- wait for next batch of events @@ -1847,10 +1847,10 @@ function UIManager:_standbyTransition() self._prev_prevent_standby_count = self._prevent_standby_count end --- Used by a PM transition event handler to request an early return from input polling (value in s). +-- Used by a PM transition event handler to request an early return from input polling. -- NOTE: We can't re-use setInputTimeout to avoid interactions with ZMQ... -function UIManager:setPMInputTimeout(timeout) - self.PM_INPUT_TIMEOUT = timeout +function UIManager:consumeInputEarlyAfterPM(toggle) + self._pm_consume_input_early = toggle end --- Broadcasts a `FlushSettings` Event to *all* widgets. diff --git a/plugins/autosuspend.koplugin/main.lua b/plugins/autosuspend.koplugin/main.lua index 122446cf4..04c6b82cb 100644 --- a/plugins/autosuspend.koplugin/main.lua +++ b/plugins/autosuspend.koplugin/main.lua @@ -605,7 +605,7 @@ function AutoSuspend:AllowStandbyHandler() -- even when there isn't actually any user input happening (e.g., woken up by the rtc alarm). -- This shouldn't prevent us from actually consuming any pending input events first, -- because if we were woken up by user input, those events should already be in the evdev queue... - UIManager:setPMInputTimeout(0) + UIManager:consumeInputEarlyAfterPM(true) end end