Make Inverted Portrait a first-class citizen (#5783)

* Don't store stale screen/rotation modes in book's settings!

Gyro events *may* entirely bypass the local copy...
In any case, using a local copy was essentially asking for trouble...

Actually fix #5772

(because the issue was indeed that a Gyro swap from Portrait to Inverted
Portrait wasn't stored properly).

* Allow showing ScreenSavers in Inverted Portrait.

That works just fine, and won't lead to the confusing situation where a
lefty might pick up the device as a righty because the ScreenSaver
happens to be shown that way, only to have it rotate back to its lefty
orientation on wakeup...
pull/5789/head
NiLuJe 4 years ago committed by GitHub
parent 2d02ade498
commit f44b031702
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -47,9 +47,16 @@ local Screen = Device.screen
local T = require("ffi/util").template
local function restoreScreenMode()
local screen_mode = G_reader_settings:readSetting("fm_screen_mode")
--- @todo: Not Yet Implemented. Layout is currently broken in Landscape.
local screen_mode = G_reader_settings:readSetting("fm_screen_mode") or "portrait"
--- @note: Basically, if we were already in Portrait/Inverted Portrait, don't mess with it,
-- as the FM supports it.
-- See setScreenMode in base's ffi/framebuffer.lua for the gory details.
-- See also ReaderView:onSetScreenMode in apps/reader/modules/readerview.lua for a similar logic,
-- if we ever need to add Landscape to the mix.
-- c.f., https://github.com/koreader/koreader/issues/5772#issuecomment-577242365
if Screen:getScreenMode() ~= screen_mode then
Screen:setScreenMode(screen_mode or "portrait")
Screen:setScreenMode(screen_mode)
end
end

@ -693,7 +693,6 @@ function ReaderView:onSetScreenMode(new_mode, rotation, noskip)
return true
end
if new_mode == "landscape" or new_mode == "portrait" then
self.screen_mode = new_mode
-- NOTE: Hacky hack! If rotation is "true", that's actually an "interactive" flag for setScreenMode
--- @fixme That's because we can't store nils in a table, which is what Event:new attempts to do ;).
-- c.f., <https://stackoverflow.com/q/7183998/> & <http://lua-users.org/wiki/VarargTheSecondClassCitizen>
@ -710,7 +709,6 @@ function ReaderView:onSetScreenMode(new_mode, rotation, noskip)
self.ui:onScreenResize(new_screen_size)
self.ui:handleEvent(Event:new("InitScrollPageStates"))
end
self.cur_rotation_mode = Screen:getRotationMode()
return true
end
@ -758,7 +756,6 @@ function ReaderView:onReadSettings(config)
screen_mode = config:readSetting("screen_mode") or G_reader_settings:readSetting("copt_screen_mode") or "portrait"
end
if screen_mode then
Screen:setScreenMode(screen_mode)
self:onSetScreenMode(screen_mode, config:readSetting("rotation_mode"), true)
end
self.state.gamma = config:readSetting("gamma") or 1.0
@ -846,8 +843,8 @@ end
function ReaderView:onSaveSettings()
self.ui.doc_settings:saveSetting("render_mode", self.render_mode)
self.ui.doc_settings:saveSetting("screen_mode", self.screen_mode)
self.ui.doc_settings:saveSetting("rotation_mode", self.cur_rotation_mode)
self.ui.doc_settings:saveSetting("screen_mode", Screen:getScreenMode())
self.ui.doc_settings:saveSetting("rotation_mode", Screen:getRotationMode())
self.ui.doc_settings:saveSetting("gamma", self.state.gamma)
self.ui.doc_settings:saveSetting("highlight", self.highlight.saved)
self.ui.doc_settings:saveSetting("page_overlap_style", self.page_overlap_style)

@ -205,7 +205,7 @@ function Device:onPowerEvent(ev)
network_manager:scheduleConnectivityCheck()
end
self:resume()
-- restore to previous rotation mode, if need be.
-- Restore to previous rotation mode, if need be.
if self.orig_rotation_mode then
self.screen:setRotationMode(self.orig_rotation_mode)
end
@ -228,11 +228,17 @@ function Device:onPowerEvent(ev)
self.powerd:beforeSuspend()
local UIManager = require("ui/uimanager")
logger.dbg("Suspending...")
-- Mostly always suspend in portrait mode...
-- ... except when we just show an InfoMessage, it plays badly with landscape mode (c.f., #4098)
-- Mostly always suspend in Portrait/Inverted Portrait mode...
-- ... except when we just show an InfoMessage, it plays badly with Landscape mode (c.f., #4098)
if G_reader_settings:readSetting("screensaver_type") ~= "message" then
self.orig_rotation_mode = self.screen:getRotationMode()
self.screen:setRotationMode(0)
-- Leave Portrait & Inverted Portrait alone, that works just fine.
if bit.band(self.orig_rotation_mode, 1) == 1 then
-- i.e., only switch to Portrait if we're currently in *any* Landscape orientation (odd number)
self.screen:setRotationMode(0)
else
self.orig_rotation_mode = nil
end
-- On eInk, if we're using a screensaver mode that shows an image,
-- flash the screen to white first, to eliminate ghosting.

Loading…
Cancel
Save