Skip to content

Commit

Permalink
[fix] Let UIManager handle suspend logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Frenzie committed Sep 1, 2019
1 parent 621f36b commit 2600abe
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions frontend/ui/uimanager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,19 @@ function UIManager:init()
self.event_handlers["PowerRelease"] = function()
if not self._entered_poweroff_stage then
UIManager:unschedule(self.poweroff_action)
self:_beforeSuspend()
Device:intoScreenSaver()
Device:suspend()
-- resume if we were suspended
if Device.screen_saver_mode then
self:resume()
else
self:suspend()
end
end
end
self.event_handlers["Suspend"] = self.event_handlers["PowerRelease"]
self.event_handlers["Suspend"] = function()
self:_beforeSuspend()
Device:intoScreenSaver()
Device:suspend()
end
self.event_handlers["Resume"] = function()
Device:resume()
Device:outofScreenSaver()
Expand All @@ -230,7 +237,12 @@ function UIManager:init()
self.event_handlers["PowerRelease"] = function()
if not self._entered_poweroff_stage then
UIManager:unschedule(self.poweroff_action)
self:suspend()
-- resume if we were suspended
if Device.screen_saver_mode then
self:resume()
else
self:suspend()
end
end
end
self.event_handlers["Charging"] = function()
Expand Down

0 comments on commit 2600abe

Please sign in to comment.