From b0498ec9b9a598938b44e3c8835ebfe17304c657 Mon Sep 17 00:00:00 2001 From: chrox Date: Thu, 18 Aug 2016 23:47:51 +0800 Subject: [PATCH] revert 9ab005a changes to UIManager:sendEvent which would make readerui handle swipe event twice. And use broadcastEvent to emit `FlushSettings` event. This should fix #2225 and fix #2226. --- frontend/device/generic/device.lua | 4 ++-- frontend/ui/uimanager.lua | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/frontend/device/generic/device.lua b/frontend/device/generic/device.lua index 3926c4108..31da49049 100644 --- a/frontend/device/generic/device.lua +++ b/frontend/device/generic/device.lua @@ -90,7 +90,7 @@ function Device:intoScreenSaver() os.execute("killall -cont awesome") end end - UIManager:sendEvent(Event:new("FlushSettings")) + UIManager:broadcastEvent(Event:new("FlushSettings")) end -- ONLY used for Kindle devices @@ -121,7 +121,7 @@ function Device:onPowerEvent(ev) local UIManager = require("ui/uimanager") -- flushing settings first in case the screensaver takes too long time -- that flushing has no chance to run - UIManager:sendEvent(Event:new("FlushSettings")) + UIManager:broadcastEvent(Event:new("FlushSettings")) DEBUG("Suspending...") -- always suspend in portrait mode self.orig_rotation_mode = self.screen:getRotationMode() diff --git a/frontend/ui/uimanager.lua b/frontend/ui/uimanager.lua index 726650d30..abe985a7b 100644 --- a/frontend/ui/uimanager.lua +++ b/frontend/ui/uimanager.lua @@ -402,7 +402,7 @@ function UIManager:sendEvent(event) end end - -- if the event is not consumed, widgets (from top to bottom) can + -- if the event is not consumed, active widgets (from top to bottom) can -- access it. NOTE: _window_stack can shrink on close event local checked_widgets = {top_widget} for i = #self._window_stack, 1, -1 do @@ -416,11 +416,13 @@ function UIManager:sendEvent(event) if active_widget:handleEvent(event) then return end end end - -- ordinary widgets will handle this event - -- Note: is_always_active widgets currently are vitualkeyboard and - -- readerconfig - checked_widgets[widget] = true - if widget.widget:handleEvent(event) then return end + if widget.widget.is_always_active then + -- active widgets will handle this event + -- Note: is_always_active widgets currently are vitualkeyboard and + -- readerconfig + checked_widgets[widget] = true + if widget.widget:handleEvent(event) then return end + end end end end