From 7e6de308893da1099d423d8d5f63457522eb4691 Mon Sep 17 00:00:00 2001 From: Frans de Jonge Date: Thu, 22 Mar 2018 19:13:54 +0100 Subject: [PATCH] [feat, UX] SDL2: drop file to open (#3793) Includes: * crengine: use cache files renamed as .cr3.keep https://github.com/koreader/crengine/pull/137 --- base | 2 +- frontend/device/sdl/device.lua | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/base b/base index f92a6b5d8..520fcf62b 160000 --- a/base +++ b/base @@ -1 +1 @@ -Subproject commit f92a6b5d80af0d9b18050a0ba99a1d6f02924ad6 +Subproject commit 520fcf62b0fb1197a3fd6196629ba2f38d248c4b diff --git a/frontend/device/sdl/device.lua b/frontend/device/sdl/device.lua index 40f22c7ff..a6353146f 100644 --- a/frontend/device/sdl/device.lua +++ b/frontend/device/sdl/device.lua @@ -43,12 +43,19 @@ function Device:init() 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 + -- bit of a hack for passing SDL events + local SDL_DROPFILE = 4096 local SDL_WINDOWEVENT_RESIZED = 5 local w = 0 local h = 1 - if ev.code == w then + if ev.code == SDL_DROPFILE then + local dropped_file_path = input.getDroppedFilePath() + if dropped_file_path and dropped_file_path ~= "" then + local ReaderUI = require("apps/reader/readerui") + ReaderUI:doShowReader(dropped_file_path) + end + elseif ev.code == w then device_input.new_w = ev.value elseif ev.code == h then device_input.new_h = ev.value