summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2019-11-18 15:25:51 +0100
committerSimon Rettberg2019-11-18 15:25:51 +0100
commit173aaca316daae968fc82cbaa1e333610ec847a4 (patch)
tree8358b6616594062cf063edf7ee11494835f573b3
parentRemove docs for showLockDesktopButton (diff)
downloadpvs2-master.tar.gz
pvs2-master.tar.xz
pvs2-master.zip
[server] Periodically deactivate xscreensaver when clients are connectedHEADv26master
-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;