fix crash in goint into screen saver

pull/2/merge
Qingping Hou 11 years ago
parent 01e1f72bdd
commit dd7e26a986

@ -83,28 +83,23 @@ function Device:intoScreenSaver()
--os.execute("echo 'screensaver in' >> /mnt/us/event_test.txt")
if self.charging_mode == false and self.screen_saver_mode == false then
Screen:saveCurrentBB()
msg = InfoMessage:new{
text = "Going into screensaver... ",
timeout = 2,
}
--UIManager:show(msg)
--Screen.kpv_rotation_mode = Screen.cur_rotation_mode
--Screen.fb:setOrientation(Screen.native_rotation_mode)
--UIManager:show(InfoMessage:new{
--text = "Going into screensaver... ",
--timeout = 2,
--})
--util.sleep(1)
--os.execute("killall -cont cvm")
self.screen_saver_mode = true
--UIManager:close(msg)
end
end
function Device:outofScreenSaver()
--os.execute("echo 'screensaver out' >> /mnt/us/event_test.txt")
if self.screen_saver_mode == true and self.charging_mode == false then
--util.usleep(1500000)
-- wait for native system update screen before we recover saved
-- Blitbuffer.
util.usleep(1500000)
--os.execute("killall -stop cvm")
--Screen.fb:setOrientation(Screen.kpv_rotation_mode)
Screen:restoreFromSavedBB()
Screen:refresh(0)
end
@ -115,12 +110,10 @@ function Device:usbPlugIn()
--os.execute("echo 'usb in' >> /mnt/us/event_test.txt")
if self.charging_mode == false and self.screen_saver_mode == false then
Screen:saveCurrentBB()
--Screen.kpv_rotation_mode = Screen.cur_rotation_mode
--Screen.fb:setOrientation(Screen.native_rotation_mode)
msg = InfoMessage:new{
text = "Going into USB mode... ",
timeout = 2,
}
--UIManager:show(InfoMessage:new{
--text = "Going into USB mode... ",
--timeout = 2,
--})
--util.sleep(1)
--os.execute("killall -cont cvm")
end
@ -132,14 +125,10 @@ function Device:usbPlugOut()
if self.charging_mode == true and self.screen_saver_mode == false then
--util.usleep(1500000)
--os.execute("killall -stop cvm")
--Screen.fb:setOrientation(Screen.kpv_rotation_mode)
Screen:restoreFromSavedBB()
Screen:refresh(0)
end
--@TODO signal filemanager for file changes 13.06 2012 (houqp)
--FileChooser:setPath(FileChooser.path)
--FileChooser.pagedirty = true
self.charging_mode = false
end

@ -123,6 +123,12 @@ an interface to get input events
]]
Input = {
event_map = {},
rotation_map = {
[0] = {},
[1] = { Up = "Right", Right = "Down", Down = "Left", Left = "Up" },
[2] = { Up = "Down", Right = "Left", Down = "Up", Left = "Right" },
[3] = { Up = "Left", Right = "Up", Down = "Right", Left = "Down" }
},
rotation = 0,
timer_callbacks = {},
}
@ -194,12 +200,6 @@ function Input:initKeyMap()
[117] = "RPgFwd", -- normal PageDown
[119] = "Del", -- Delete
}
self.rotation_map = {
[0] = {},
[1] = { Up = "Right", Right = "Down", Down = "Left", Left = "Up" },
[2] = { Up = "Down", Right = "Left", Down = "Up", Left = "Right" },
[3] = { Up = "Left", Right = "Up", Down = "Right", Left = "Down" }
}
self.modifiers = {
Alt = false,
Shift = false
@ -245,7 +245,7 @@ end
function Input:init()
-- Screen module must have been initilized by now.
self.rotation = Screen.fb:getOrientation()
self.rotation = Screen:getRotationMode()
if Device:hasKeyboard() then
self:initKeyMap()

@ -72,27 +72,6 @@ function Screen:refresh(refesh_type)
self.fb:refresh(refesh_type)
end
-- @orien: 1 for clockwise rotate, -1 for anti-clockwise
-- Remember to reread screen resolution after this function call
-- WARNING: this method is deprecated!!! use setRotationMode() or
-- setViewMode() instead.
function Screen:screenRotate(orien)
if orien == "clockwise" then
orien = -1
elseif orien == "anticlockwise" then
orien = 1
else
return
end
self.cur_rotation_mode = (self.cur_rotation_mode + orien) % 4
-- you have to reopen framebuffer after rotate
self.fb:setOrientation(self.cur_rotation_mode)
self.fb:close()
self.fb = einkfb.open("/dev/fb0")
Input.rotation = self.cur_rotation_mode
end
function Screen:getSize()
return Geom:new{w = self.width, h = self.height}
end
@ -109,12 +88,20 @@ function Screen:getPitch()
return self.ptich
end
function Screen:updateRotationMode()
function Screen:getNativeRotationMode()
-- in EMU mode, you will always get 0 from getOrientation()
self.cur_rotation_mode = self.fb:getOrientation()
return self.fb:getOrientation()
end
function Screen:getRotationMode()
return self.cur_rotation_mode
end
function Screen:setRotationMode(mode)
if mode > 3 or mode < 0 then
return
end
-- mode 0 and mode 2 has the same width and height, so do mode 1 and 3
if (self.cur_rotation_mode % 2) ~= (mode % 2) then
self.width, self.height = self.height, self.width
@ -123,6 +110,8 @@ function Screen:setRotationMode(mode)
self.bb:free()
self.pitch = self.width/2
self.bb = Blitbuffer.new(self.width, self.height, self.pitch)
-- update mode for input module
Input.rotation = mode
end
function Screen:setViewMode(mode)
@ -167,7 +156,7 @@ function Screen:saveCurrentBB()
self.saved_bb:free()
self.saved_bb = Blitbuffer.new(width, height, self:getPitch())
end
self.saved_bb:blitFullFrom(self.fb.bb)
self.saved_bb:blitFullFrom(self.bb)
end
function Screen:restoreFromSavedBB()
@ -176,13 +165,13 @@ end
function Screen:getCurrentScreenBB()
local bb = Blitbuffer.new(self:getWidth(), self:getHeight())
bb:blitFullFrom(self.fb.bb)
bb:blitFullFrom(self.bb)
return bb
end
function Screen:restoreFromBB(bb)
if bb then
self.fb.bb:blitFullFrom(bb)
self.bb:blitFullFrom(bb)
else
DEBUG("Got nil bb in restoreFromSavedBB!")
end

@ -97,8 +97,6 @@ if fontmap ~= nil then
end
local last_file = G_reader_settings:readSetting("lastfile")
Screen:updateRotationMode()
Screen.native_rotation_mode = Screen.cur_rotation_mode
--@TODO we can read version here, refer to commit in master tree: (houqp)
--87712cf0e43fed624f8a9f610be42b1fe174b9fe
@ -118,14 +116,9 @@ else
return showusage()
end
-- @TODO dirty workaround, find a way to force native system poll
-- screen orientation and upside down mode 09.03 2012
Screen:setRotationMode(Screen.native_rotation_mode)
input.closeAll()
if util.isEmulated()==0 then
os.execute("killall -cont cvm")
if Device:isKindle3() or (Device:getModel() == "KindleDXG") then
-- send double menu key press events to trigger screen refresh
os.execute("echo 'send 139' > /proc/keypad;echo 'send 139' > /proc/keypad")

Loading…
Cancel
Save