From e7a575b4c41ed2296f36e2e5a2a19b85819f0a3a Mon Sep 17 00:00:00 2001 From: Guldoman Date: Mon, 10 Oct 2022 02:13:51 +0200 Subject: [PATCH] Use relative mouse position directly for drop event (#1140) Previously the relative position was calculated using the window position and the global mouse coordinates. In some systems like wayland, this operation returns incorrect values. --- src/api/system.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/api/system.c b/src/api/system.c index 052d15f4..40018cd5 100644 --- a/src/api/system.c +++ b/src/api/system.c @@ -158,7 +158,7 @@ static void push_win32_error(lua_State *L, DWORD rc) { static int f_poll_event(lua_State *L) { char buf[16]; - int mx, my, wx, wy; + int mx, my; SDL_Event e; top: @@ -209,12 +209,11 @@ top: goto top; case SDL_DROPFILE: - SDL_GetGlobalMouseState(&mx, &my); - SDL_GetWindowPosition(window, &wx, &wy); + SDL_GetMouseState(&mx, &my); lua_pushstring(L, "filedropped"); lua_pushstring(L, e.drop.file); - lua_pushinteger(L, mx - wx); - lua_pushinteger(L, my - wy); + lua_pushinteger(L, mx); + lua_pushinteger(L, my); SDL_free(e.drop.file); return 4;