[gnome-settings-daemon] power: Fix battery state with multiple batteries
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] power: Fix battery state with multiple batteries
- Date: Tue, 17 Sep 2013 16:36:07 +0000 (UTC)
commit 22c4d34fc89d3507bbb62ed2a843e22b8007f318
Author: Bastien Nocera <hadess hadess net>
Date: Tue Sep 17 16:07:27 2013 +0200
power: Fix battery state with multiple batteries
When using 2 batteries, one charging, one discharging, the overall
state should be "discharging".
plugins/power/gsd-power-manager.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index deb6868..341dbfb 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -734,16 +734,17 @@ engine_update_composite_device (GsdPowerManager *manager)
if (battery_devices == 0) {
state = UP_DEVICE_STATE_UNKNOWN;
goto out;
+ }
/* use percentage weighted for each battery capacity */
if (energy_full_total > 0.0)
percentage = 100.0 * energy_total / energy_full_total;
/* set composite state */
- if (is_charging)
- state = UP_DEVICE_STATE_CHARGING;
- else if (is_discharging)
+ if (is_discharging)
state = UP_DEVICE_STATE_DISCHARGING;
+ else if (is_charging)
+ state = UP_DEVICE_STATE_CHARGING;
else if (is_fully_charged)
state = UP_DEVICE_STATE_FULLY_CHARGED;
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]