mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2026-05-08 07:48:05 +02:00
Use a gdouble for percentage.
The percentage field of the device object is a gdouble. Low battery calculations should read this field as a gdouble instead of a guint to get the correct value. This fixes the case where clients see on-low-battery possibly changing with every percentage of battery discharge. Signed-off-by: Byron Clark <byron@theclarkfamily.name>
This commit is contained in:
parent
a0cac7f1ca
commit
1dbe1c87c5
1 changed files with 2 additions and 2 deletions
|
|
@ -161,7 +161,7 @@ dkp_device_supply_get_low_battery (DkpDevice *device, gboolean *low_battery)
|
|||
gboolean ret;
|
||||
gboolean on_battery;
|
||||
DkpDeviceSupply *supply = DKP_DEVICE_SUPPLY (device);
|
||||
guint percentage;
|
||||
gdouble percentage;
|
||||
|
||||
g_return_val_if_fail (DKP_IS_SUPPLY (supply), FALSE);
|
||||
g_return_val_if_fail (low_battery != NULL, FALSE);
|
||||
|
|
@ -178,7 +178,7 @@ dkp_device_supply_get_low_battery (DkpDevice *device, gboolean *low_battery)
|
|||
}
|
||||
|
||||
g_object_get (device, "percentage", &percentage, NULL);
|
||||
*low_battery = (percentage < 10);
|
||||
*low_battery = (percentage < 10.0f);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue