Avoid updating the frequency if it did not change

This commit is contained in:
Manuel Bouyer 2018-04-12 17:49:10 +02:00 committed by Pierre Pronchery
parent 30645bac55
commit 41e9ec3b3f

View File

@ -42,6 +42,7 @@ typedef struct _PanelApplet
guint timeout; guint timeout;
int min; int min;
int max; int max;
int current;
int step; int step;
#if defined(__FreeBSD__) || defined(__NetBSD__) #if defined(__FreeBSD__) || defined(__NetBSD__)
char const * name; char const * name;
@ -129,6 +130,7 @@ static Cpufreq * _cpufreq_init(PanelAppletHelper * helper, GtkWidget ** widget)
cpufreq->max = atoi(freq); cpufreq->max = atoi(freq);
cpufreq->min = (p = strrchr(freq, ' ')) != NULL ? atoi(p) cpufreq->min = (p = strrchr(freq, ' ')) != NULL ? atoi(p)
: cpufreq->max; : cpufreq->max;
cpufreq->current = -1;
cpufreq->step = 1; cpufreq->step = 1;
cpufreq->name = p; cpufreq->name = p;
cpufreq->label = gtk_label_new(" "); cpufreq->label = gtk_label_new(" ");
@ -182,6 +184,9 @@ static gboolean _cpufreq_on_timeout(gpointer data)
helper->error(NULL, error_get(NULL), 1); helper->error(NULL, error_get(NULL), 1);
return TRUE; return TRUE;
} }
if(cpufreq->current == (int)freq)
return TRUE;
cpufreq->current = freq;
snprintf(buf, sizeof(buf), "%4u", (unsigned int)freq); snprintf(buf, sizeof(buf), "%4u", (unsigned int)freq);
gtk_label_set_text(GTK_LABEL(cpufreq->label), buf); gtk_label_set_text(GTK_LABEL(cpufreq->label), buf);
# if GTK_CHECK_VERSION(2, 12, 0) # if GTK_CHECK_VERSION(2, 12, 0)