Implement pause on lost focus on SDL

This option was Windows exclusive and this commit implements it on SDL
as well.

It is hidden on mobile devices because it makes no sense there.
This commit is contained in:
Guido Cella
2026-04-01 15:39:34 +02:00
parent 030c7a9e6b
commit 4413c7b10f
4 changed files with 22 additions and 3 deletions
+3
View File
@@ -318,6 +318,9 @@ static const ConfigSetting generalSettings[] = {
#if defined(USING_WIN_UI)
ConfigSetting("TopMost", SETTING(g_Config, bTopMost), false, CfgFlag::DEFAULT),
#endif
#if defined(USING_WIN_UI) || (defined (SDL) && !defined(MOBILE_DEVICE))
ConfigSetting("PauseOnLostFocus", SETTING(g_Config, bPauseOnLostFocus), false, CfgFlag::PER_GAME),
#endif
+2 -2
View File
@@ -195,9 +195,9 @@ public:
int iLogOutputTypes; // enum class LogOutput
int iDumpFileTypes; // DumpFileType bitflag enum
bool bFullscreenOnDoubleclick;
// These four are Win UI only
bool bPauseOnLostFocus;
// These are Win UI only
bool bTopMost;
bool bIgnoreWindowsKey;
bool bRestartRequired;
+16
View File
@@ -997,6 +997,22 @@ static void ProcessSDLEvent(SDL_Window *window, const SDL_Event &event, InputSta
break;
}
case SDL_WINDOWEVENT_FOCUS_LOST:
{
if (g_Config.bPauseOnLostFocus && GetUIState() == UISTATE_INGAME) {
Core_Break(BreakReason::UIFocus, 0);
}
}
break;
case SDL_WINDOWEVENT_FOCUS_GAINED:
{
if (Core_BreakReason() == BreakReason::UIFocus) {
Core_Resume();
}
}
break;
case SDL_WINDOWEVENT_MINIMIZED:
case SDL_WINDOWEVENT_HIDDEN:
Native_NotifyWindowHidden(true);
+1 -1
View File
@@ -1431,7 +1431,7 @@ void GameSettingsScreen::CreateSystemSettings(UI::ViewGroup *systemSettings) {
static const char *screenshotModeChoices[] = { "Final processed image", "Raw game image" };
systemSettings->Add(new PopupMultiChoice(&g_Config.iScreenshotMode, sy->T("Screenshot mode"), screenshotModeChoices, 0, ARRAY_SIZE(screenshotModeChoices), I18NCat::SYSTEM, screenManager()));
// TODO: Make this setting available on Mac too.
#if PPSSPP_PLATFORM(WINDOWS)
#if PPSSPP_PLATFORM(WINDOWS) || (defined (SDL) && !defined(MOBILE_DEVICE))
systemSettings->Add(new CheckBox(&g_Config.bPauseOnLostFocus, sy->T("Pause when not focused")));
#endif