From 1f98321fa6139105a1b427a2dac2b4e2b0642dd6 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 22 Jul 2014 12:19:20 -0500 Subject: make the notification popup decision logic simpler & easier to read --- src/notifier.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/notifier.c b/src/notifier.c index 326f5a1..81662ca 100644 --- a/src/notifier.c +++ b/src/notifier.c @@ -167,9 +167,11 @@ on_battery_property_changed (IndicatorPowerNotifier * self) old_discharging = p->discharging; new_discharging = indicator_power_device_get_state(p->battery) == UP_DEVICE_STATE_DISCHARGING; - if (new_discharging && - (new_power_level != POWER_LEVEL_OK) && - ((new_power_level != old_power_level) || (new_discharging != old_discharging))) + /* pop up a notification for a battery whenever either: + a) it's already discharging, and its PowerLevel worsens, OR + b) it's already got a bad PowerLevel and its state becomes 'discharging */ + if ((new_discharging && (new_power_level > old_power_level)) || + ((new_power_level != POWER_LEVEL_OK) && new_discharging && !old_discharging)) { notification_show (self); } -- cgit v1.2.3