split out FocusChanged
This commit is contained in:
+16
-12
@@ -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()
|
static void HandleSDLEvents()
|
||||||
{
|
{
|
||||||
// process all queued events
|
// process all queued events
|
||||||
@@ -1498,18 +1513,7 @@ static void HandleSDLEvents()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
uint8_t i = SDL_GetAppState();
|
uint8_t i = SDL_GetAppState();
|
||||||
|
FocusChanged( i&SDL_APPINPUTFOCUS && i&SDL_APPACTIVE );
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user