1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
From 31fcf4c07346bc1fcd7b6df07b62330fd0b7db7f Mon Sep 17 00:00:00 2001
From: Nate Graham <nate@kde.org>
Date: Tue, 17 Jun 2025 15:38:49 -0600
Subject: [PATCH] PowerDevilAction: refresh action timers on inhibition changes
When inhibitions change, action timers should be restarted.
If they're not restarted, action timer may run to 0 right after
a video playback ends for example, running the action abruptly.
BUG: 504553
(cherry picked from commit 3feaad466c5e6195ed8541c3c58d899a612511d0)
Co-authored-by: Akseli Lahtinen <akselmo@akselmo.dev>
---
daemon/powerdevilcore.cpp | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/daemon/powerdevilcore.cpp b/daemon/powerdevilcore.cpp
index fc154cab4..bd97fb7ec 100644
--- a/daemon/powerdevilcore.cpp
+++ b/daemon/powerdevilcore.cpp
@@ -141,6 +141,17 @@ void Core::onControllersReady()
Q_UNUSED(newPolicies);
KIdleTime::instance()->simulateUserActivity();
});
+ // Refresh action timers during inhibition change, to avoid timers reaching zero right after inhibitions end.
+ connect(PowerDevil::PolicyAgent::instance(), &PowerDevil::PolicyAgent::InhibitionsChanged, this, [this]() {
+ qCDebug(POWERDEVIL) << "Refreshing timers for actions on inhibitionsChanged";
+ for (const QString &action : std::as_const(m_activeActions)) {
+ const auto timeouts = m_actionPool[action]->m_registeredIdleTimeouts;
+ m_actionPool[action]->unregisterIdleTimeouts();
+ for (const auto &timeout : timeouts) {
+ m_actionPool[action]->registerIdleTimeout(timeout);
+ }
+ }
+ });
// Bug 354250: Simulate user activity when session becomes inactive,
// this keeps us from sending the computer to sleep when switching to an idle session.
--
GitLab
|