diff options
author | Simon Rettberg | 2019-11-18 15:25:51 +0100 |
---|---|---|
committer | Simon Rettberg | 2019-11-18 15:25:51 +0100 |
commit | 173aaca316daae968fc82cbaa1e333610ec847a4 (patch) | |
tree | 8358b6616594062cf063edf7ee11494835f573b3 | |
parent | Remove docs for showLockDesktopButton (diff) | |
download | pvs2-173aaca316daae968fc82cbaa1e333610ec847a4.tar.gz pvs2-173aaca316daae968fc82cbaa1e333610ec847a4.tar.xz pvs2-173aaca316daae968fc82cbaa1e333610ec847a4.zip |
[server] Periodically deactivate xscreensaver when clients are connectedv26
-rw-r--r-- | src/server/util/platform/screensaver.cpp | 19 |
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; |