summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/util/platform/screensaver.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/server/util/platform/screensaver.cpp b/src/server/util/platform/screensaver.cpp
index cdd6ee1..569a4a3 100644
--- a/src/server/util/platform/screensaver.cpp
+++ b/src/server/util/platform/screensaver.cpp
@@ -3,6 +3,7 @@
#include <QX11Info>
#include <QStringList>
#include <QProcess>
+#include <QTimer>
#include <X11/Xlib.h>
#ifdef X11_Xscreensaver_FOUND
@@ -17,6 +18,7 @@ namespace {
Display *display = nullptr;
bool extensionSupported = false;
bool dpmsSupported = false;
+ QTimer *timer = nullptr;
bool init()
{
@@ -51,16 +53,25 @@ namespace ScreenSaver {
return;
}
#endif
- // TODO: Maybe try some fallback, call xset, or trigger some event periodically
+ if (allow) {
+ if (timer != nullptr) {
+ timer->stop();
+ }
+ } else {
+ if (timer == nullptr) {
+ timer = new QTimer;
+ QObject::connect(timer, &QTimer::timeout, forceUnlockAndScreenOn);
+ }
+ timer->setSingleShot(false);
+ timer->start(55000);
+ }
}
void forceUnlockAndScreenOn()
{
if (!init())
return;
- QProcess process;
- process.start("xscreensaver-command", QStringList() << "-deactivate");
- process.waitForFinished(100);
+ QProcess::startDetached("xscreensaver-command", QStringList() << "-deactivate");
#ifdef X11_dpms_FOUND
CARD16 power_level;
BOOL state;