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