Fixed mouse-position resolution when dropping a file
This commit is contained in:
parent
08ce7e2563
commit
7aabfebfa0
|
@ -317,8 +317,8 @@ function core.on_event(type, ...)
|
||||||
elseif type == "mousewheel" then
|
elseif type == "mousewheel" then
|
||||||
core.root_view:on_mouse_wheel(...)
|
core.root_view:on_mouse_wheel(...)
|
||||||
elseif type == "filedropped" then
|
elseif type == "filedropped" then
|
||||||
local mx, my = core.root_view.mouse.x, core.root_view.mouse.y
|
local filename, mx, my = ...
|
||||||
local ok, doc = core.try(core.open_doc, select(1, ...))
|
local ok, doc = core.try(core.open_doc, filename)
|
||||||
if ok then
|
if ok then
|
||||||
local node = core.root_view.root_node:get_child_overlapping_point(mx, my)
|
local node = core.root_view.root_node:get_child_overlapping_point(mx, my)
|
||||||
node:set_active_view(node.active_view)
|
node:set_active_view(node.active_view)
|
||||||
|
|
|
@ -36,6 +36,7 @@ static char* key_name(char *dst, int sym) {
|
||||||
|
|
||||||
static int f_poll_event(lua_State *L) {
|
static int f_poll_event(lua_State *L) {
|
||||||
char buf[16];
|
char buf[16];
|
||||||
|
int mx, my, wx, wy;
|
||||||
SDL_Event e;
|
SDL_Event e;
|
||||||
|
|
||||||
top:
|
top:
|
||||||
|
@ -66,10 +67,14 @@ top:
|
||||||
goto top;
|
goto top;
|
||||||
|
|
||||||
case SDL_DROPFILE:
|
case SDL_DROPFILE:
|
||||||
|
SDL_GetGlobalMouseState(&mx, &my);
|
||||||
|
SDL_GetWindowPosition(window, &wx, &wy);
|
||||||
lua_pushstring(L, "filedropped");
|
lua_pushstring(L, "filedropped");
|
||||||
lua_pushstring(L, e.drop.file);
|
lua_pushstring(L, e.drop.file);
|
||||||
|
lua_pushnumber(L, mx - wx);
|
||||||
|
lua_pushnumber(L, my - wy);
|
||||||
SDL_free(e.drop.file);
|
SDL_free(e.drop.file);
|
||||||
return 2;
|
return 4;
|
||||||
|
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
lua_pushstring(L, "keypressed");
|
lua_pushstring(L, "keypressed");
|
||||||
|
|
Loading…
Reference in a new issue