Wait until window receives focus to respect pauseOnFocusLost

This commit is contained in:
Luke Street
2026-05-10 22:08:04 -06:00
parent 9315919091
commit 211bfb00a8
+6
View File
@@ -50,6 +50,7 @@ std::atomic_bool g_surfaceReady = false;
std::atomic_bool g_surfaceReady = true;
#endif
bool g_lastPaused = false;
bool g_gotFocus = false;
bool operator==(const AuroraWindowSize& lhs, const AuroraWindowSize& rhs) {
return lhs.width == rhs.width && lhs.height == rhs.height && lhs.fb_width == rhs.fb_width &&
@@ -445,6 +446,11 @@ bool is_paused() noexcept {
if ((flags & SDL_WINDOW_HIDDEN) != 0u) {
return true;
}
// Wait until the window has received focus before respecting pauseOnFocusLost
if (!g_gotFocus) {
g_gotFocus = (flags & SDL_WINDOW_INPUT_FOCUS) != 0u;
return false;
}
return g_config.pauseOnFocusLost && ((flags & SDL_WINDOW_INPUT_FOCUS) == 0u || (flags & SDL_WINDOW_MINIMIZED) != 0u);
}