PrusaSlicer-NonPlainar/xs/src/slic3r/GUI/GUI.cpp

55 lines
1.0 KiB
C++
Raw Normal View History

#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 {
2015-12-05 10:48:24 +00:00
#if __APPLE__
IOPMAssertionID assertionID;
2015-12-05 10:48:24 +00:00
#endif
2017-10-25 10:53:31 +00:00
void disable_screensaver()
{
#if __APPLE__
CFStringRef reasonForActivity = CFSTR("Slic3r");
IOReturn success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep,
kIOPMAssertionLevelOn, reasonForActivity, &assertionID);
// ignore result: success == kIOReturnSuccess
#elif _WIN32
2015-12-06 10:17:50 +00:00
SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_CONTINUOUS);
#endif
}
2017-10-25 10:53:31 +00:00
void enable_screensaver()
{
#if __APPLE__
IOReturn success = IOPMAssertionRelease(assertionID);
#elif _WIN32
2015-12-06 10:17:50 +00:00
SetThreadExecutionState(ES_CONTINUOUS);
#endif
}
2017-10-25 10:53:31 +00:00
bool debugged()
{
#ifdef _WIN32
return IsDebuggerPresent();
#else
return false;
#endif /* _WIN32 */
}
2017-10-25 10:53:31 +00:00
void break_to_debugger()
{
#ifdef _WIN32
if (IsDebuggerPresent())
DebugBreak();
#endif /* _WIN32 */
}
} }