From abcea2244d9c909febb05f87aa9937e5c31d418a Mon Sep 17 00:00:00 2001 From: miruka Date: Thu, 16 Jul 2020 19:09:09 -0400 Subject: [PATCH] Make libX11 & libXScrnSaver optional on Linux --- TODO.md | 1 - mirage.pro | 7 +++++++ src/gui/IdleManager.qml | 4 +++- src/main.cpp | 1 + src/utils.h | 7 +++++-- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/TODO.md b/TODO.md index ec27752e..23bc5602 100644 --- a/TODO.md +++ b/TODO.md @@ -8,7 +8,6 @@ - fix HLabeledItem disabled opacity (visible for the topic area in room settings) -- ~~save and restore status message in accounts.json~~ - mark accounts as offline when closing mirage - document new libXScreenSaver-devel dependency (for auto-idle) - retrieve last seen time for offline members on hover/in profile/automatically diff --git a/mirage.pro b/mirage.pro index 530902b2..027ba27e 100644 --- a/mirage.pro +++ b/mirage.pro @@ -36,6 +36,7 @@ unix:!macx { # Custom CONFIG options dev { + # Enable debugging and don't use the Qt Resource System to compile faster CONFIG -= warn_off release CONFIG += debug qml_debug declarative_debug RESOURCES -= $$QRC_FILE @@ -43,6 +44,12 @@ dev { warning(make install cannot be used with the dev CONFIG option.) } +no-x11 { + # Compile without X11-specific features (auto-away) + DEFINES += NO_X11 + LIBS -= -lX11 -lXss +} + # Files to copy for `make install` diff --git a/src/gui/IdleManager.qml b/src/gui/IdleManager.qml index 046df980..94d434b3 100644 --- a/src/gui/IdleManager.qml +++ b/src/gui/IdleManager.qml @@ -14,8 +14,10 @@ Timer { interval: 1000 - running: window.settings.beUnavailableAfterSecondsIdle > 0 repeat: true + running: + window.settings.beUnavailableAfterSecondsIdle > 0 && + CppUtils.idleMilliseconds() !== -1 onTriggered: { let changes = false diff --git a/src/main.cpp b/src/main.cpp index f12d0a7b..23737013 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #ifdef Q_OS_UNIX #include diff --git a/src/utils.h b/src/utils.h index 004bd52b..ee4d52cd 100644 --- a/src/utils.h +++ b/src/utils.h @@ -12,7 +12,10 @@ #include #ifdef Q_OS_UNIX -#include + #ifndef NO_X11 + #define USE_UNIX_AUTOAWAY + #include + #endif #endif #include "../submodules/hsluv-c/src/hsluv.h" @@ -51,7 +54,7 @@ public slots: #ifdef Q_OS_DARWIN return -1; - #elif defined(Q_OS_UNIX) + #elif defined(USE_UNIX_AUTOAWAY) Display *display = XOpenDisplay(NULL); if (! display) return -1;