diff --git a/Sources/Plasma/Apps/plClient/CMakeLists.txt b/Sources/Plasma/Apps/plClient/CMakeLists.txt index bd42ba35e5..d9ae3b20b8 100644 --- a/Sources/Plasma/Apps/plClient/CMakeLists.txt +++ b/Sources/Plasma/Apps/plClient/CMakeLists.txt @@ -246,6 +246,7 @@ target_link_libraries( CURL::libcurl "$<$:-framework Cocoa>" "$<$:-framework QuartzCore>" + "$<$:-framework IOKit>" ) target_include_directories(plClient PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/Sources/Plasma/Apps/plClient/Mac-Cocoa/main.mm b/Sources/Plasma/Apps/plClient/Mac-Cocoa/main.mm index 0059ef3ebd..3875ee87ac 100644 --- a/Sources/Plasma/Apps/plClient/Mac-Cocoa/main.mm +++ b/Sources/Plasma/Apps/plClient/Mac-Cocoa/main.mm @@ -49,6 +49,7 @@ #import #endif #import +#import // Cocoa client #import "NSString+StringTheory.h" @@ -64,6 +65,7 @@ #include // Plasma engine +#include "hsDarwin.h" #include "plClient/plClient.h" #include "plClient/plClientLoader.h" #include "plCmdParser.h" @@ -478,6 +480,16 @@ - (void)startClient ((PLSView*)self.window.contentView).inputManager = gClient->GetInputManager(); [self.window makeFirstResponder:self.window.contentView]; + IOPMAssertionID assertionID = 0; +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 + IOReturn result = IOPMAssertionCreateWithName(kIOPMAssertionTypePreventUserIdleDisplaySleep, kIOPMAssertionLevelOn, CFStringCreateWithSTString(plProduct::LongName()), &assertionID); +#else + IOReturn result = IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &assertionID); +#endif + if (result != kIOReturnSuccess) { + hsStatusMessage("Failed to acquire idle prevention assertion"); + } + // Main loop if (gClient && !gClient->GetDone()) { [self startRunLoop];