#include "GUI.hpp" #if __APPLE__ #import #elif _WIN32 #include #pragma comment(lib, "user32.lib") #endif namespace Slic3r { namespace GUI { IOPMAssertionID assertionID; void disable_screensaver() { #if __APPLE__ CFStringRef reasonForActivity = CFSTR("Slic3r"); IOReturn success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, reasonForActivity, &assertionID); // ignore result: success == kIOReturnSuccess #elif _WIN32 SetThreadExecutionState(EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS); #endif } void enable_screensaver() { #if __APPLE__ IOReturn success = IOPMAssertionRelease(assertionID); #elif _WIN32 SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS); #endif } } }