[sysprof] battery: only submit event if battery value changed



commit 555a10ef6511c47bd19a26280ab28990fb2e3693
Author: Christian Hergert <chergert redhat com>
Date:   Thu Jun 13 19:04:11 2019 -0700

    battery: only submit event if battery value changed

 src/libsysprof/sysprof-battery-source.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/src/libsysprof/sysprof-battery-source.c b/src/libsysprof/sysprof-battery-source.c
index a978bee..0b12a6e 100644
--- a/src/libsysprof/sysprof-battery-source.c
+++ b/src/libsysprof/sysprof-battery-source.c
@@ -157,6 +157,7 @@ static gboolean
 battery_poll (Battery                    *battery,
               SysprofCaptureCounterValue *value)
 {
+  gint64 val;
   gssize len;
   gchar buf[32];
 
@@ -183,11 +184,16 @@ battery_poll (Battery                    *battery,
 
   buf [len] = 0;
 
-  battery->charge_now = atoi (buf);
+  val = atoi (buf);
 
-  value->v64 = battery->charge_now;
+  if (val != battery->charge_now)
+    {
+      battery->charge_now = val;
+      value->v64 = val;
+      return TRUE;
+    }
 
-  return TRUE;
+  return FALSE;
 }
 
 static gboolean


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]