From ea0e52c5a2e1c30f006bd9aef97fadd195395dd6 Mon Sep 17 00:00:00 2001 From: o9000 Date: Tue, 20 Jun 2017 18:58:13 +0200 Subject: [PATCH] Battery format fixes --- src/battery/battery.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/battery/battery.c b/src/battery/battery.c index adcf87a..7c0bf1a 100644 --- a/src/battery/battery.c +++ b/src/battery/battery.c @@ -170,7 +170,9 @@ void battery_update_text(char *dest, char *format) ? "Charging" : (battery_state.state == BATTERY_DISCHARGING) ? "Discharging" - : (battery_state.state == BATTERY_FULL) ? "Full" : "Unknown", + : (battery_state.state == BATTERY_FULL || battery_state.percentage >= 100) + ? "Full" + : "Unknown", BATTERY_BUF_SIZE); break; case 'm': @@ -186,7 +188,8 @@ void battery_update_text(char *dest, char *format) strnappend(dest, buf, BATTERY_BUF_SIZE); break; case 't': - if (battery_state.state == BATTERY_FULL) { + if (battery_state.state == BATTERY_FULL || + (battery_state.state == BATTERY_UNKNOWN && battery_state.percentage >= 100)) { snprintf(buf, sizeof(buf), "Full"); strnappend(dest, buf, BATTERY_BUF_SIZE); } else { @@ -386,11 +389,7 @@ int update_battery() int battery_compute_desired_size(void *obj) { Battery *battery = (Battery *)obj; - return text_area_compute_desired_size(&battery->area, - buf_bat_line1, - buf_bat_line2, - bat1_font_desc, - bat2_font_desc); + return text_area_compute_desired_size(&battery->area, buf_bat_line1, buf_bat_line2, bat1_font_desc, bat2_font_desc); } gboolean resize_battery(void *obj)