From 43a405413bf385eed556f95d62d4e891cb52877f Mon Sep 17 00:00:00 2001 From: Davide Pesavento Date: Fri, 2 Jan 2026 21:24:40 -0500 Subject: [PATCH] PlatformMisc: Fix screensaver inhibition on macOS (#3674) --- src/util/platform_misc_mac.mm | 15 ++++++++------- src/util/platform_misc_unix.cpp | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/util/platform_misc_mac.mm b/src/util/platform_misc_mac.mm index 25f4b4043..c09f879a7 100644 --- a/src/util/platform_misc_mac.mm +++ b/src/util/platform_misc_mac.mm @@ -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; } diff --git a/src/util/platform_misc_unix.cpp b/src/util/platform_misc_unix.cpp index 1b7bbaf17..3dc9aa6ca 100644 --- a/src/util/platform_misc_unix.cpp +++ b/src/util/platform_misc_unix.cpp @@ -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() {