File tree Expand file tree Collapse file tree 2 files changed +12
-11
lines changed
Expand file tree Collapse file tree 2 files changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,6 @@ const char *OS::getCPU() const {
7676}
7777
7878
79- bool OS::isOnBattery () const {return PowerManagement::instance ().onBattery ();}
8079void OS::dispatch () {app.getEventBase ().dispatch ();}
8180
8281
@@ -97,12 +96,13 @@ void OS::update() {
9796 app.triggerUpdate ();
9897 }
9998
100- paused = app.getPaused ();
101- active = app.isActive ();
102- failure = app.hasFailure ();
99+ auto &pm = PowerManagement::instance ();
100+ paused = app.getPaused ();
101+ active = app.isActive ();
102+ failure = app.hasFailure ();
103+ onBattery = pm.onBattery ();
103104
104105 // Keep system awake if not on battery
105- auto &pwrMan = PowerManagement::instance ();
106- if (!pwrMan.onBattery () && app.keepAwake ()) lastKeepAwake = Time::now ();
107- pwrMan.allowSystemSleep (30 < Time::now () - lastKeepAwake);
106+ if (!onBattery && app.keepAwake ()) lastKeepAwake = Time::now ();
107+ pm.allowSystemSleep (30 < Time::now () - lastKeepAwake);
108108}
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ namespace FAH {
4646 std::atomic<bool > paused;
4747 std::atomic<bool > active;
4848 std::atomic<bool > failure;
49+ std::atomic<bool > onBattery;
4950
5051 protected:
5152 cb::SmartPointer<cb::Event::Event> event;
@@ -59,12 +60,12 @@ namespace FAH {
5960 virtual const char *getName () const = 0;
6061 virtual const char *getCPU () const ;
6162 virtual bool isSystemIdle () const = 0;
62- virtual bool isOnBattery () const ;
6363 virtual void dispatch ();
6464
65- bool isPaused () const {return paused;}
66- bool isActive () const {return active;}
67- bool hasFailure () const {return failure;}
65+ bool isPaused () const {return paused;}
66+ bool isActive () const {return active;}
67+ bool hasFailure () const {return failure;}
68+ bool isOnBattery () const {return onBattery;}
6869 void requestExit () const ;
6970 void setState (const std::string &state) const ;
7071
You can’t perform that action at this time.
0 commit comments