IdleService: make execution chain more streamlined

This commit is contained in:
Lysec
2026-02-28 23:35:16 +01:00
parent 9596db0b39
commit a7b558d3fe
+14 -2
View File
@@ -41,6 +41,7 @@ Singleton {
property var _suspendMonitor: null
property var _heartbeatMonitor: null
property var _customMonitors: ({})
property real _suppressUntil: 0
// Signals for external listeners (plugins, modules)
signal screenOffRequested
@@ -60,11 +61,18 @@ Singleton {
repeat: false
onTriggered: {
const action = root.fadePending;
root.fadePending = "";
root._executeAction(action);
overlayCleanupTimer.start();
}
}
Timer {
id: overlayCleanupTimer
interval: 500
repeat: false
onTriggered: root.fadePending = ""
}
// Counts up idleSeconds while the heartbeat monitor reports idle
Timer {
id: idleCounter
@@ -80,12 +88,14 @@ Singleton {
Logger.i("IdleService", "Fade cancelled for:", fadePending);
fadePending = "";
graceTimer.stop();
overlayCleanupTimer.stop();
}
function _onIdle(stage) {
// Don't re-trigger if already fading something
if (fadePending !== "")
return;
if (Date.now() < _suppressUntil)
return;
Logger.i("IdleService", "Idle fired:", stage);
fadePending = stage;
graceTimer.restart();
@@ -94,6 +104,7 @@ Singleton {
function _executeAction(stage) {
Logger.i("IdleService", "Executing action:", stage);
if (stage === "screenOff") {
root._suppressUntil = Date.now() + 15000;
CompositorService.turnOffMonitors();
root.screenOffRequested();
} else if (stage === "lock") {
@@ -264,6 +275,7 @@ Singleton {
idleCounter.stop();
root.idleSeconds = 0;
root.cancelFade();
overlayCleanupTimer.stop();
}
});
_heartbeatMonitor = monitor;