active.state is a bitflag, so this should work even on Windows and still ignore the annoying focus switch on mouse-over.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@1609 4a71c877-e1ca-e34f-864e-861f7616d084
master
Dennis Schridde 2007-05-12 08:20:33 +00:00
parent f8bd53fc62
commit 981d56f328
1 changed files with 20 additions and 21 deletions

View File

@ -182,31 +182,30 @@ static void processEvent(SDL_Event *event)
switch(event->type)
{
case SDL_ACTIVEEVENT:
#if defined(WZ_OS_LINUX)
// Ignore focus gain through SDL_APPMOUSEFOCUS on Linux, since it mostly happens accidentialy, while on Windows this is the only possibility to gain focus
if ( event->active.gain == 1 && event->active.state != SDL_APPMOUSEFOCUS )
#else
if ( event->active.gain == 1 )
#endif
{
debug( LOG_NEVER, "WM_SETFOCUS\n");
if (focusState != FOCUS_IN)
{
debug( LOG_NEVER, "FOCUS_SET\n");
focusState = FOCUS_SET;
}
}
// Ignore focus loss through SDL_APPMOUSEFOCUS, since it mostly happens accidentialy
else if ( event->active.state != SDL_APPMOUSEFOCUS )
// active.state is a bitflag! Mixed events (eg. APPACTIVE|APPMOUSEFOCUS) will thus not be ignored.
if ( event->active.state != SDL_APPMOUSEFOCUS )
{
debug( LOG_NEVER, "WM_KILLFOCUS\n");
if (focusState != FOCUS_OUT)
if ( event->active.gain == 1 )
{
debug( LOG_NEVER, "FOCUS_KILL\n");
focusState = FOCUS_KILL;
debug( LOG_NEVER, "WM_SETFOCUS\n");
if (focusState != FOCUS_IN)
{
debug( LOG_NEVER, "FOCUS_SET\n");
focusState = FOCUS_SET;
}
}
else
{
debug( LOG_NEVER, "WM_KILLFOCUS\n");
if (focusState != FOCUS_OUT)
{
debug( LOG_NEVER, "FOCUS_KILL\n");
focusState = FOCUS_KILL;
}
/* Have to tell the input system that we've lost focus */
inputLooseFocus();
}
/* Have to tell the input system that we've lost focus */
inputLooseFocus();
}
break;
case SDL_KEYUP: