]> git.sur5r.net Git - minitube/blob - src/idle/src/idle_win.cpp
2f189eff02305dbde31cf91de254f5449b57481e
[minitube] / src / idle / src / idle_win.cpp
1 #include "idle.h"
2
3 #include "windows.h"
4
5 namespace {
6 EXECUTION_STATE executionState;
7 }
8
9 bool Idle::preventDisplaySleep(const QString &reason) {
10     executionState = SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
11     return true;
12 }
13
14 bool Idle::allowDisplaySleep() {
15     SetThreadExecutionState(ES_CONTINUOUS | executionState);
16     return true;
17 }
18
19 QString Idle::displayErrorMessage() {
20     return QString();
21 }
22
23 bool Idle::preventSystemSleep(const QString &reason) {
24     executionState = SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED);
25     return true;
26 }
27
28 bool Idle::allowSystemSleep() {
29     SetThreadExecutionState(ES_CONTINUOUS | executionState);
30     return true;
31 }
32
33 QString Idle::systemErrorMessage() {
34     return QString();
35 }