diff --git a/client/SDL/SDL3/sdl_context.cpp b/client/SDL/SDL3/sdl_context.cpp index 0942de432..016fd1831 100644 --- a/client/SDL/SDL3/sdl_context.cpp +++ b/client/SDL/SDL3/sdl_context.cpp @@ -840,6 +840,18 @@ wLog* SdlContext::getWLog() return _log; } +bool SdlContext::moveMouseTo(const SDL_FPoint& pos) +{ + auto window = SDL_GetMouseFocus(); + if (!window) + return true; + + const auto id = SDL_GetWindowID(window); + const auto spos = pixelToScreen(id, pos); + SDL_WarpMouseInWindow(window, spos.x, spos.y); + return true; +} + bool SdlContext::handleEvent(const SDL_WindowEvent* ev) { diff --git a/client/SDL/SDL3/sdl_context.hpp b/client/SDL/SDL3/sdl_context.hpp index 4b98a8807..0cbee1c64 100644 --- a/client/SDL/SDL3/sdl_context.hpp +++ b/client/SDL/SDL3/sdl_context.hpp @@ -120,6 +120,8 @@ class SdlContext [[nodiscard]] wLog* getWLog(); + [[nodiscard]] bool moveMouseTo(const SDL_FPoint& pos); + [[nodiscard]] SDL_FPoint screenToPixel(SDL_WindowID id, const SDL_FPoint& pos); [[nodiscard]] SDL_FPoint pixelToScreen(SDL_WindowID id, const SDL_FPoint& pos); diff --git a/client/SDL/SDL3/sdl_freerdp.cpp b/client/SDL/SDL3/sdl_freerdp.cpp index 613674bd2..0af737663 100644 --- a/client/SDL/SDL3/sdl_freerdp.cpp +++ b/client/SDL/SDL3/sdl_freerdp.cpp @@ -288,18 +288,9 @@ static int sdl_run(SdlContext* sdl) static_cast(reinterpret_cast(windowEvent.user.data1)); const auto y = static_cast(reinterpret_cast(windowEvent.user.data2)); - - SDL_Window* window = SDL_GetMouseFocus(); - if (window) - { - const Uint32 id = SDL_GetWindowID(window); - - INT32 sx = x; - INT32 sy = y; - if (sdl_scale_coordinates(sdl, id, &sx, &sy, FALSE, FALSE)) - SDL_WarpMouseInWindow(window, static_cast(sx), - static_cast(sy)); - } + if (!sdl->moveMouseTo( + { static_cast(x) * 1.0f, static_cast(y) * 1.0f })) + return -1; } break; case SDL_EVENT_USER_POINTER_SET: