diff --git a/data/core/init.lua b/data/core/init.lua index 23a83197..12435a6a 100644 --- a/data/core/init.lua +++ b/data/core/init.lua @@ -317,8 +317,8 @@ function core.on_event(type, ...) elseif type == "mousewheel" then core.root_view:on_mouse_wheel(...) elseif type == "filedropped" then - local mx, my = core.root_view.mouse.x, core.root_view.mouse.y - local ok, doc = core.try(core.open_doc, select(1, ...)) + local filename, mx, my = ... + local ok, doc = core.try(core.open_doc, filename) if ok then local node = core.root_view.root_node:get_child_overlapping_point(mx, my) node:set_active_view(node.active_view) diff --git a/src/api/system.c b/src/api/system.c index bacafcb5..fbb917ee 100644 --- a/src/api/system.c +++ b/src/api/system.c @@ -36,6 +36,7 @@ static char* key_name(char *dst, int sym) { static int f_poll_event(lua_State *L) { char buf[16]; + int mx, my, wx, wy; SDL_Event e; top: @@ -66,10 +67,14 @@ top: goto top; case SDL_DROPFILE: + SDL_GetGlobalMouseState(&mx, &my); + SDL_GetWindowPosition(window, &wx, &wy); lua_pushstring(L, "filedropped"); lua_pushstring(L, e.drop.file); + lua_pushnumber(L, mx - wx); + lua_pushnumber(L, my - wy); SDL_free(e.drop.file); - return 2; + return 4; case SDL_KEYDOWN: lua_pushstring(L, "keypressed");