Cleverer UIManager <-> PowerD circular dependency handling

Thanks to @poire-z ;).
pull/8721/head
NiLuJe 2 years ago committed by Frans de Jonge
parent 2462c1c5c1
commit e39ee325f9

@ -1,3 +1,4 @@
local UIManager -- will be updated when available
local TimeVal = require("ui/timeval")
local logger = require("logger")
local BasePowerD = {
@ -27,6 +28,10 @@ function BasePowerD:new(o)
return o
end
function BasePowerD:readyUI()
UIManager = require("ui/uimanager")
end
function BasePowerD:init() end
function BasePowerD:setIntensityHW(intensity) end
function BasePowerD:getCapacityHW() return 0 end
@ -153,8 +158,7 @@ function BasePowerD:getCapacity()
-- BasePowerD is loaded before UIManager.
-- Nothing *currently* calls this before UIManager is actually loaded, but future-proof this anyway.
local now_ts
if package.loaded["ui/uimanager"] ~= nil then
local UIManager = require("ui/uimanager")
if UIManager then
now_ts = UIManager:getTime()
else
now_ts = TimeVal:now()
@ -173,8 +177,7 @@ end
function BasePowerD:getAuxCapacity()
local now_ts
if package.loaded["ui/uimanager"] ~= nil then
local UIManager = require("ui/uimanager")
if UIManager then
now_ts = UIManager:getTime()
else
now_ts = TimeVal:now()
@ -206,9 +209,8 @@ end
function BasePowerD:stateChanged()
-- BasePowerD is loaded before UIManager. So we cannot broadcast events before UIManager has been loaded.
if package.loaded["ui/uimanager"] ~= nil then
if UIManager then
local Event = require("ui/event")
local UIManager = require("ui/uimanager")
UIManager:broadcastEvent(Event:new("FrontlightStateChanged"))
end
end

@ -1722,6 +1722,10 @@ It is intended to manage input events and delegate them to dialogs.
--]]
function UIManager:run()
self._running = true
-- Tell PowerD that we're ready
Device:getPowerDevice():readyUI()
self:initLooper()
-- currently there is no Turbo support for Windows
-- use our own main loop

Loading…
Cancel
Save