hvclock_update(gpointer data)
{
GtkWidget *clock = GTK_WIDGET(data);
+ static struct tm previous;
+ struct tm *now;
+ int update = false;
- hvclock_redraw_canvas(clock);
+ now = clock_get_time();
+
+ /* Update only if time has changed. If the hours or minutes have
+ * changed, force update. */
+ if ((now->tm_hour != previous.tm_hour) ||
+ (now->tm_min != previous.tm_min)) {
+ update = true;
+ }
+
+ /* If the seconds have changed, force update only if displaying of
+ * the seconds hand is requested. */
+ if (hvclock_infos.show_seconds && (now->tm_sec != previous.tm_sec)) {
+ update = true;
+ }
+
+ if (update) {
+ hvclock_redraw_canvas(clock);
+ previous = *now;
+ }
return TRUE; /* keep running this event */
}