Input: Process input events in batches (#7483)

Requires https://github.com/koreader/koreader-base/pull/1344 & https://github.com/koreader/koreader-base/pull/1346 (fix #7485)

Assorted input fixes:

* Actually handle errors in the "there's a callback timer" input polling loop.
* Don't break timerfd when the clock probe was inconclusive.

Not directly related, but noticed because of duplicate onInputEvent handlers:

* HookContainer: Fix deregistration to actually deregister properly. "Regression" extant since its inception in #2933 (!).
* Made sure the three plugins (basically the trio of AutoThingies ;p) that were using HookContainer actually unschedule their task on teardown.
This commit is contained in:
NiLuJe
2021-04-03 01:48:35 +02:00
committed by GitHub
parent 25aabd69d9
commit 03e9fac156
10 changed files with 134 additions and 78 deletions

View File

@@ -1549,7 +1549,7 @@ end
-- Process all pending events on all registered ZMQs.
function UIManager:processZMQs()
for _, zeromq in ipairs(self._zeromqs) do
for input_event in zeromq.waitEvent,zeromq do
for input_event in zeromq.waitEvent, zeromq do
self:handleInputEvent(input_event)
end
end
@@ -1611,12 +1611,15 @@ function UIManager:handleInput()
-- Anywhere else breaks preventStandby/allowStandby invariants used by background jobs while UI is left running.
self:_standbyTransition()
-- wait for next event
local input_event = Input:waitEvent(now, deadline)
-- wait for next batch of events
local input_events = Input:waitEvent(now, deadline)
-- delegate input_event to handler
if input_event then
self:handleInputEvent(input_event)
-- delegate each input event to handler
if input_events then
-- Handle the full batch of events
for __, ev in ipairs(input_events) do
self:handleInputEvent(ev)
end
end
if self.looper then
@@ -1637,7 +1640,7 @@ end
function UIManager:onRotation()
self:setDirty('all', 'full')
self:setDirty("all", "full")
self:forceRePaint()
end