From 01a3163d40f4a13870de63b025ce738aaab07ada Mon Sep 17 00:00:00 2001 From: dottools Date: Mon, 30 May 2022 16:09:48 -0500 Subject: [PATCH 1/2] Engine GUI: Don't translate mouse coordinates in GuiCanvas::setCursorPos() Removed translating passed mouse pointer coordinates from client to screen space. Source comments and exposed canvas script API help doc line for the same function states that passed mouse pointer coordinates are supposed to already be in screen space. --- Engine/source/gui/core/guiCanvas.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Engine/source/gui/core/guiCanvas.cpp b/Engine/source/gui/core/guiCanvas.cpp index 95f6213c2..2549a4ed2 100644 --- a/Engine/source/gui/core/guiCanvas.cpp +++ b/Engine/source/gui/core/guiCanvas.cpp @@ -549,8 +549,7 @@ void GuiCanvas::setCursorPos(const Point2I &pt) } else { - Point2I screenPt( mPlatformWindow->clientToScreen( pt ) ); - mPlatformWindow->setCursorPosition( screenPt.x, screenPt.y ); + mPlatformWindow->setCursorPosition(pt.x, pt.y); } } From 0f81ececaededdc0e3235cf2f31fdd8583520c91 Mon Sep 17 00:00:00 2001 From: dottools Date: Mon, 30 May 2022 16:14:18 -0500 Subject: [PATCH 2/2] Engine SDL: Use screen space coordinates for both mouse pointer set and get position Changed mouse pointer coordinates from client to screen space. Done in order to be consistent with existing engine comments, API help doc string, and how it used to work in Win32 window management code. --- Engine/source/windowManager/sdl/sdlCursorController.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Engine/source/windowManager/sdl/sdlCursorController.cpp b/Engine/source/windowManager/sdl/sdlCursorController.cpp index 601df4e19..f4d8913c9 100644 --- a/Engine/source/windowManager/sdl/sdlCursorController.cpp +++ b/Engine/source/windowManager/sdl/sdlCursorController.cpp @@ -64,17 +64,12 @@ S32 PlatformCursorControllerSDL::getDoubleClickHeight() void PlatformCursorControllerSDL::setCursorPosition( S32 x, S32 y ) { - if( PlatformWindowManager::get() && PlatformWindowManager::get()->getFirstWindow() ) - { - AssertFatal( dynamic_cast( PlatformWindowManager::get()->getFirstWindow() ), ""); - PlatformWindowSDL *window = static_cast( PlatformWindowManager::get()->getFirstWindow() ); - SDL_WarpMouseInWindow(window->getSDLWindow(), x, y); - } + SDL_WarpMouseGlobal(x, y); } void PlatformCursorControllerSDL::getCursorPosition( Point2I &point ) { - SDL_GetMouseState( &point.x, &point.y ); + SDL_GetGlobalMouseState( &point.x, &point.y ); } void PlatformCursorControllerSDL::setCursorVisible( bool visible )