From 981d56f328d533451e1a8a34e90873d9c59ee919 Mon Sep 17 00:00:00 2001 From: Dennis Schridde Date: Sat, 12 May 2007 08:20:33 +0000 Subject: [PATCH] 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 --- lib/framework/frame.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/lib/framework/frame.c b/lib/framework/frame.c index 4a581b2d8..8998ed16e 100644 --- a/lib/framework/frame.c +++ b/lib/framework/frame.c @@ -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: