diff --git a/source/shared_lib/sources/platform/common/platform_common.cpp b/source/shared_lib/sources/platform/common/platform_common.cpp index 921dbf6b..0386117d 100644 --- a/source/shared_lib/sources/platform/common/platform_common.cpp +++ b/source/shared_lib/sources/platform/common/platform_common.cpp @@ -783,6 +783,7 @@ void showCursor(bool b) { //SDL_GetMouseState( &x, &y ); } SDL_ShowCursor(b ? SDL_ENABLE : SDL_DISABLE); + SDL_WM_GrabInput(SDL_GRAB_OFF); if(b) { //SDL_WM_GrabInput(SDL_GRAB_OFF); //SDL_WarpMouse(x,y); diff --git a/source/shared_lib/sources/platform/sdl/gl_wrap.cpp b/source/shared_lib/sources/platform/sdl/gl_wrap.cpp index 453584ba..492d54a0 100644 --- a/source/shared_lib/sources/platform/sdl/gl_wrap.cpp +++ b/source/shared_lib/sources/platform/sdl/gl_wrap.cpp @@ -91,6 +91,8 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits) { << depthBits << " depth-buffer). SDL Error is: " << SDL_GetError(); throw std::runtime_error(msg.str()); } + + SDL_WM_GrabInput(SDL_GRAB_OFF); } void PlatformContextGl::end() { diff --git a/source/shared_lib/sources/platform/sdl/window.cpp b/source/shared_lib/sources/platform/sdl/window.cpp index ff99c9e5..b7431d1f 100644 --- a/source/shared_lib/sources/platform/sdl/window.cpp +++ b/source/shared_lib/sources/platform/sdl/window.cpp @@ -186,9 +186,7 @@ bool Window::handleEvent() { } SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::isActive = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::isActive); - if(Window::isActive && Window::getUseDefaultCursorOnly() == false) { - showCursor(!Window::isActive); - } + showCursor(!Window::isActive || Window::getUseDefaultCursorOnly()); } // Check if the program has lost window focus else if (event.active.state == SDL_APPACTIVE) { @@ -200,9 +198,7 @@ bool Window::handleEvent() { } SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::isActive = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::isActive); - if(Window::isActive && Window::getUseDefaultCursorOnly() == false) { - showCursor(!Window::isActive); - } + showCursor(!Window::isActive || Window::getUseDefaultCursorOnly()); } // Check if the program has lost window focus else if (event.active.state == SDL_APPMOUSEFOCUS) { @@ -214,9 +210,7 @@ bool Window::handleEvent() { } SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::isActive = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::isActive); - if(Window::isActive && Window::getUseDefaultCursorOnly() == false) { - showCursor(!Window::isActive); - } + showCursor(!Window::isActive || Window::getUseDefaultCursorOnly()); } else { if (event.active.gain == 0) { @@ -227,9 +221,7 @@ bool Window::handleEvent() { } SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::isActive = %d, event.active.state = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::isActive,event.active.state); - if(Window::isActive && Window::getUseDefaultCursorOnly() == false) { - showCursor(!Window::isActive); - } + showCursor(!Window::isActive || Window::getUseDefaultCursorOnly()); } } @@ -431,7 +423,7 @@ void Window::toggleFullscreen() { if(Window::isFullScreen == true) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] Window::isFullScreen == true [%d]\n",__FILE__,__FUNCTION__,__LINE__,handle); ShowWindow(handle, SW_MAXIMIZE); - if(Window::isActive && Window::getUseDefaultCursorOnly() == false) { + if(Window::getUseDefaultCursorOnly() == false) { showCursor(false); } }