diff --git a/source/shared_lib/sources/platform/common/platform_common.cpp b/source/shared_lib/sources/platform/common/platform_common.cpp index 496718a3a..9dc9b8484 100644 --- a/source/shared_lib/sources/platform/common/platform_common.cpp +++ b/source/shared_lib/sources/platform/common/platform_common.cpp @@ -818,7 +818,7 @@ void sleep(int millis) { } void showCursor(bool b) { - int x,y; + //int x,y; if(b) { //SDL_GetMouseState( &x, &y ); } @@ -828,12 +828,12 @@ void showCursor(bool b) { return; } - SDL_ShowCursor(b ? SDL_ENABLE : SDL_DISABLE); + SDL_ShowCursor(b == true ? SDL_ENABLE : SDL_DISABLE); //SDL_WM_GrabInput(SDL_GRAB_OFF); - if(b) { + //if(b) { //SDL_WM_GrabInput(SDL_GRAB_OFF); //SDL_WarpMouse(x,y); - } + //} } bool isKeyDown(int virtualKey) { diff --git a/source/shared_lib/sources/platform/sdl/window.cpp b/source/shared_lib/sources/platform/sdl/window.cpp index 7287e2e92..7250de486 100644 --- a/source/shared_lib/sources/platform/sdl/window.cpp +++ b/source/shared_lib/sources/platform/sdl/window.cpp @@ -201,12 +201,30 @@ bool Window::handleEvent() { codeLocation = "k"; SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] SDL_ACTIVEEVENT.\n",__FILE__,__FUNCTION__,__LINE__); - // Check if the program has lost keyboard focus + // Check if the program has lost keyboard focus + /* if (event.active.state == SDL_APPINPUTFOCUS) { if (event.active.gain == 0) { Window::isActive = false; } - else if (event.active.gain == 1) { + //else if (event.active.gain == 1) { + else { + Window::isActive = true; + } + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::isActive = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::isActive); + + bool willShowCursor = (!Window::isActive || (Window::lastShowMouseState == SDL_ENABLE) || Window::getUseDefaultCursorOnly()); + showCursor(willShowCursor); + } + */ + // Check if the program has lost window focus + if (event.active.state == SDL_APPACTIVE) { + if (event.active.gain == 0) { + Window::isActive = false; + } + //else if (event.active.gain == 1) { + else { Window::isActive = true; } @@ -215,38 +233,30 @@ bool Window::handleEvent() { bool willShowCursor = (!Window::isActive || (Window::lastShowMouseState == SDL_ENABLE) || Window::getUseDefaultCursorOnly()); showCursor(willShowCursor); } - // Check if the program has lost window focus - else if (event.active.state == SDL_APPACTIVE) { + // Check if the program has lost window focus + /* + if (event.active.state == SDL_APPMOUSEFOCUS) { if (event.active.gain == 0) { Window::isActive = false; } - else if (event.active.gain == 1) { - Window::isActive = true; - } - - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::isActive = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::isActive); - - bool willShowCursor = (!Window::isActive || (Window::lastShowMouseState == SDL_ENABLE) || Window::getUseDefaultCursorOnly()); - showCursor(willShowCursor); - } - // Check if the program has lost window focus - else if (event.active.state == SDL_APPMOUSEFOCUS) { - if (event.active.gain == 0) { - Window::isActive = false; - } - else if (event.active.gain == 1) { + //else if (event.active.gain == 1) { + else { Window::isActive = true; } SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::isActive = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::isActive); bool willShowCursor = (!Window::isActive || (Window::lastShowMouseState == SDL_ENABLE) || Window::getUseDefaultCursorOnly()); showCursor(willShowCursor); - } - else { + } + */ + if (event.active.state != SDL_APPMOUSEFOCUS && + event.active.state != SDL_APPINPUTFOCUS && + event.active.state != SDL_APPACTIVE) { if (event.active.gain == 0) { Window::isActive = false; } - else if (event.active.gain == 1) { + //else if (event.active.gain == 1) { + else { Window::isActive = true; }