From bd9494fd436d87a5038127313798690579fbd16f Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 14 Jun 2004 02:13:44 +0000 Subject: [PATCH] split out FocusChanged --- stepmania/src/StepMania.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index b89e042937..f9a771081b 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -1478,6 +1478,21 @@ static void HandleInputEvents(float fDeltaTime) } } +void FocusChanged( bool bHasFocus ) +{ + g_bHasFocus = bHasFocus; + + LOG->Trace( "App %s focus", g_bHasFocus? "has":"doesn't have" ); + + /* If we lose focus, we may lose input events, especially key releases. */ + INPUTFILTER->Reset(); + + if(g_bHasFocus) + BoostAppPri(); + else + RestoreAppPri(); +} + static void HandleSDLEvents() { // process all queued events @@ -1498,18 +1513,7 @@ static void HandleSDLEvents() break; uint8_t i = SDL_GetAppState(); - - g_bHasFocus = i&SDL_APPINPUTFOCUS && i&SDL_APPACTIVE; - LOG->Trace("App %s focus (%i%i)", g_bHasFocus? "has":"doesn't have", - i&SDL_APPINPUTFOCUS, i&SDL_APPACTIVE); - - /* If we lose focus, we may lose input events, especially key releases. */ - INPUTFILTER->Reset(); - - if(g_bHasFocus) - BoostAppPri(); - else - RestoreAppPri(); + FocusChanged( i&SDL_APPINPUTFOCUS && i&SDL_APPACTIVE ); } } }