SDL: only react to window focus changes if state actually changes

This commit is contained in:
Alug committed 2024-08-03 17:40:41 +02:00
1 parent cd72bce3cb
commit 5c7d9327e3
1 file changed
+16 -7
+16 -7
View File
@@ -775,6 +775,7 @@ void I_DownSample(void)
static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
{
#define FOCUSUNION (mousefocus | (kbfocus << 1))
static SDL_bool firsttimeonmouse = SDL_TRUE;
static SDL_bool mousefocus = SDL_TRUE;
static SDL_bool kbfocus = SDL_TRUE;
@@ -782,6 +783,8 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
static SDL_bool windowmoved = SDL_FALSE;
#endif
const unsigned int oldfocus = FOCUSUNION;
switch (evt.event)
{
case SDL_WINDOWEVENT_ENTER:
@@ -807,6 +810,18 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
#endif
}
#ifdef USE_FBO_OGL
if (windowmoved && rendermode == render_opengl)
{
I_DownSample();
}
#endif
if (FOCUSUNION == oldfocus) // No state change
{
return;
}
if (mousefocus && kbfocus)
{
// Tell game we got focus back, resume music if necessary
@@ -843,13 +858,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
SDLdoUngrabMouse();
}
}
#ifdef USE_FBO_OGL
if (windowmoved && rendermode == render_opengl)
{
I_DownSample();
}
#endif
#undef FOCUSUNION
}
static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type)