From cdb38730d996f83aeb6692cafdf4c95c1db8be54 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Wed, 2 Nov 2011 21:20:11 +0000 Subject: [PATCH] trying to fix alt-tab issue in windows --- .../sources/platform/sdl/window.cpp | 61 +++++++++++++------ 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/source/shared_lib/sources/platform/sdl/window.cpp b/source/shared_lib/sources/platform/sdl/window.cpp index 8c15f36e..eb1593a5 100644 --- a/source/shared_lib/sources/platform/sdl/window.cpp +++ b/source/shared_lib/sources/platform/sdl/window.cpp @@ -243,13 +243,54 @@ bool Window::handleEvent() { break; case SDL_ACTIVEEVENT: { +// codeLocation = "k"; +// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] SDL_ACTIVEEVENT event.active.state = %d event.active. = %d\n",__FILE__,__FUNCTION__,__LINE__,event.active.state,event.active.gain); +// +// if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d event.active.state = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::isActive,event.active.state); +// +// // Check if the program has lost window focus +// if ((event.active.state & SDL_APPACTIVE) == SDL_APPACTIVE) { +// if (event.active.gain == 0) { +// Window::isActive = false; +// } +// else { +// Window::isActive = true; +// } +// +// if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d \n",__FILE__,__FUNCTION__,__LINE__,Window::isActive); +// +// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) 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_APPMOUSEFOCUS) != SDL_APPMOUSEFOCUS && +// (event.active.state & SDL_APPINPUTFOCUS) != SDL_APPINPUTFOCUS && +// (event.active.state & SDL_APPACTIVE) != SDL_APPACTIVE) { +// if (event.active.gain == 0) { +// Window::isActive = false; +// } +// //else if (event.active.gain == 1) { +// else { +// Window::isActive = true; +// } +// +// if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d \n",__FILE__,__FUNCTION__,__LINE__,Window::isActive); +// +// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) 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); +// bool willShowCursor = (!Window::isActive || (Window::lastShowMouseState == SDL_ENABLE) || Window::getUseDefaultCursorOnly()); +// showCursor(willShowCursor); +// } +// } + codeLocation = "k"; if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] SDL_ACTIVEEVENT event.active.state = %d event.active. = %d\n",__FILE__,__FUNCTION__,__LINE__,event.active.state,event.active.gain); if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d event.active.state = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::isActive,event.active.state); // Check if the program has lost window focus - if ((event.active.state & SDL_APPACTIVE) == SDL_APPACTIVE) { + if ((event.active.state & (SDL_APPACTIVE | SDL_APPINPUTFOCUS))) { if (event.active.gain == 0) { Window::isActive = false; } @@ -264,24 +305,6 @@ bool Window::handleEvent() { 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_APPMOUSEFOCUS) != SDL_APPMOUSEFOCUS && - (event.active.state & SDL_APPINPUTFOCUS) != SDL_APPINPUTFOCUS && - (event.active.state & SDL_APPACTIVE) != SDL_APPACTIVE) { - if (event.active.gain == 0) { - Window::isActive = false; - } - //else if (event.active.gain == 1) { - else { - Window::isActive = true; - } - - if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d \n",__FILE__,__FUNCTION__,__LINE__,Window::isActive); - - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) 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); - bool willShowCursor = (!Window::isActive || (Window::lastShowMouseState == SDL_ENABLE) || Window::getUseDefaultCursorOnly()); - showCursor(willShowCursor); - } } break; }