mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 17:27:52 -06:00
Disable screensaver while projecting (untested on Windows)
This commit is contained in:
parent
366b364996
commit
e2b203ba8d
6 changed files with 84 additions and 3 deletions
37
xs/src/libslic3r/GUI/GUI.cpp
Normal file
37
xs/src/libslic3r/GUI/GUI.cpp
Normal file
|
@ -0,0 +1,37 @@
|
|||
#include "GUI.hpp"
|
||||
|
||||
#if __APPLE__
|
||||
#import <IOKit/pwr_mgt/IOPMLib.h>
|
||||
#elif _WIN32
|
||||
#include <Windows.h>
|
||||
#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
|
||||
}
|
||||
|
||||
} }
|
Loading…
Add table
Add a link
Reference in a new issue