[feat] SDL2: resize window (#3775)

References #1417 

Bumps base for https://github.com/koreader/koreader-base/pull/614

Also includes:
* Speedup loading from cache EPUB with many files https://github.com/koreader/crengine/pull/133
* Avoid rewriting cache file when no change were made https://github.com/koreader/crengine/pull/134
pull/3776/head
Frans de Jonge 6 years ago committed by GitHub
parent c40e2bc0e4
commit 24c0132744
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1 +1 @@
Subproject commit 2e134c9c58a9a3f52f7c58b2e1a79ee550331f89
Subproject commit 9e001e18f13cd233ce4ddf8505c3472928668297

@ -1,3 +1,4 @@
local Event = require("ui/event")
local Generic = require("device/generic/device")
local util = require("ffi/util")
local logger = require("logger")
@ -41,6 +42,31 @@ function Device:init()
self.input = require("device/input"):new{
device = self,
event_map = require("device/sdl/event_map_sdl2"),
handleMiscEv = function(device_input, ev)
-- bit of a hack for passing SDL window resize events
local SDL_WINDOWEVENT_RESIZED = 5
local w = 0
local h = 1
if ev.code == w then
device_input.new_w = ev.value
elseif ev.code == h then
device_input.new_h = ev.value
elseif ev.code == SDL_WINDOWEVENT_RESIZED then
device_input.device.screen.screen_size.w = device_input.new_w
device_input.device.screen.screen_size.h = device_input.new_h
device_input.device.screen.resize(device_input.device.screen, device_input.new_w, device_input.new_h)
local new_size = device_input.device.screen:getSize()
logger.dbg("Resizing screen to", new_size)
-- try to catch as many flies as we can
-- this means we can't just return one ScreenResize or SetDimensons event
local UIManager = require("ui/uimanager")
UIManager:handleInputEvent(Event:new("SetDimensions", new_size))
UIManager:handleInputEvent(Event:new("ScreenResize", new_size))
end
end,
hasClipboardText = function()
return input.hasClipboardText()
end,

Loading…
Cancel
Save