From ed4d2d0a1bf9ef13b823c6f672ba52c4fe8037a4 Mon Sep 17 00:00:00 2001 From: Joseph Coffland Date: Thu, 11 Jan 2024 19:32:05 +0200 Subject: [PATCH] Trigger update on battery state change --- src/fah/client/OS.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/fah/client/OS.cpp b/src/fah/client/OS.cpp index 82b8abf..c303e50 100644 --- a/src/fah/client/OS.cpp +++ b/src/fah/client/OS.cpp @@ -96,11 +96,16 @@ void OS::update() { app.triggerUpdate(); } - auto &pm = PowerManagement::instance(); - paused = app.getPaused(); - active = app.isActive(); - failure = app.hasFailure(); - onBattery = pm.onBattery(); + paused = app.getPaused(); + active = app.isActive(); + failure = app.hasFailure(); + + auto &pm = PowerManagement::instance(); + bool onBattery = pm.onBattery(); + if (this->onBattery != onBattery) { + this->onBattery = onBattery; + app.triggerUpdate(); + } // Keep system awake if not on battery if (!onBattery && app.keepAwake()) lastKeepAwake = Time::now();