PlatformMisc: Fix screensaver inhibition on macOS (#3674)

This commit is contained in:
Davide Pesavento
2026-01-02 21:24:40 -05:00
committed by GitHub
parent 632aa18df0
commit 43a405413b
2 changed files with 9 additions and 8 deletions

View File

@@ -34,7 +34,7 @@ static bool SetScreensaverInhibitMacOS(bool inhibit)
{
if (inhibit)
{
const CFStringRef reason = CFSTR("System Running");
const CFStringRef reason = CFSTR("DuckStation System Running");
if (IOPMAssertionCreateWithName(kIOPMAssertionTypePreventUserIdleDisplaySleep, kIOPMAssertionLevelOn, reason,
&s_prevent_idle_assertion) != kIOReturnSuccess)
{
@@ -52,17 +52,18 @@ static bool SetScreensaverInhibitMacOS(bool inhibit)
}
}
static bool s_screensaver_suspended;
static bool s_screensaver_suspended = false;
void PlatformMisc::SuspendScreensaver()
{
if (s_screensaver_suspended)
return;
if (!SetScreensaverInhibitMacOS(true))
{
ERROR_LOG("Failed to suspend screensaver.");
return;
}
if (!SetScreensaverInhibitMacOS(true))
{
ERROR_LOG("Failed to suspend screensaver.");
return;
}
s_screensaver_suspended = true;
}

View File

@@ -169,7 +169,7 @@ static bool SetScreensaverInhibit(bool inhibit)
return SetScreensaverInhibitDBus(inhibit, "DuckStation", "DuckStation VM is running.");
}
static bool s_screensaver_suspended;
static bool s_screensaver_suspended = false;
void PlatformMisc::SuspendScreensaver()
{