|
|
|
|
@ -46,8 +46,7 @@ void UserActivityMonitor::start() {
|
|
|
|
|
m_elapsed.start(); |
|
|
|
|
qApp->installEventFilter(this); |
|
|
|
|
const QString platform = QGuiApplication::platformName(); |
|
|
|
|
const bool wayland = platform.startsWith("wayland") || |
|
|
|
|
(platform == "xcb" && qEnvironmentVariable("XDG_SESSION_TYPE") == "wayland"); |
|
|
|
|
const bool wayland = platform.startsWith("wayland") || qEnvironmentVariable("XDG_SESSION_TYPE") == "wayland"; |
|
|
|
|
#ifdef UTUN_ACTIVITY_DBUS |
|
|
|
|
if (wayland && !m_gnomeUnavailable) { |
|
|
|
|
m_useGnome = true; |
|
|
|
|
@ -69,6 +68,7 @@ void UserActivityMonitor::stop() {
|
|
|
|
|
if (m_watching && qApp) qApp->removeEventFilter(this); |
|
|
|
|
#ifdef UTUN_ACTIVITY_KIDLETIME |
|
|
|
|
if (m_useKIdleTime) KIdleTime::instance()->stopCatchingResumeEvent(); |
|
|
|
|
disconnect(m_kIdleConnection); |
|
|
|
|
#endif |
|
|
|
|
m_watching = false; |
|
|
|
|
m_dbusPending = false; |
|
|
|
|
@ -128,7 +128,10 @@ void UserActivityMonitor::poll() {
|
|
|
|
|
startWaylandFallback(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (elapsedMs == 0) GUI_DEBUG("activity: GNOME system idle monitor ready"); |
|
|
|
|
if (!m_gnomeReadyLogged) { |
|
|
|
|
GUI_DEBUG("activity: GNOME system idle monitor ready"); |
|
|
|
|
m_gnomeReadyLogged = true; |
|
|
|
|
} |
|
|
|
|
if (reply.value() <= qulonglong(std::numeric_limits<qint64>::max())) checkIdleTime(qint64(reply.value()), elapsedMs); |
|
|
|
|
else GUI_WARN("activity: GNOME idle time out of range: %llu", (unsigned long long)reply.value()); |
|
|
|
|
}); |
|
|
|
|
@ -148,7 +151,7 @@ void UserActivityMonitor::startWaylandFallback() {
|
|
|
|
|
const int timeout = idle->addIdleTimeout(0); |
|
|
|
|
if (timeout) { |
|
|
|
|
idle->removeIdleTimeout(timeout); |
|
|
|
|
connect(idle, &KIdleTime::resumingFromIdle, this, [this] { |
|
|
|
|
m_kIdleConnection = connect(idle, &KIdleTime::resumingFromIdle, this, [this] { |
|
|
|
|
if (!m_watching || !m_useKIdleTime) return; |
|
|
|
|
GUI_DEBUG("activity: Wayland compositor reported user activity"); |
|
|
|
|
stop(); |
|
|
|
|
|