瀏覽代碼

Merge pull request #798 from dottools/fix/mouseCoordSpace

Use screen space coordinates for mouse pointer position
Brian Roberts 3 年之前
父節點
當前提交
5b9c080aef
共有 2 個文件被更改,包括 3 次插入9 次删除
  1. 1 2
      Engine/source/gui/core/guiCanvas.cpp
  2. 2 7
      Engine/source/windowManager/sdl/sdlCursorController.cpp

+ 1 - 2
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);
    }
 }
 

+ 2 - 7
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<PlatformWindowSDL*>( PlatformWindowManager::get()->getFirstWindow() ), "");
-      PlatformWindowSDL *window = static_cast<PlatformWindowSDL*>( 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 )