From fa0bf7bc4d9295b3e268a2def7d2d88597f3440a Mon Sep 17 00:00:00 2001 From: Thomas Osterland Date: Thu, 22 Mar 2018 20:43:29 +0100 Subject: [PATCH] initialize lastCheck variable in init_colors_once to replace -1 check --- unlock_indicator.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/unlock_indicator.c b/unlock_indicator.c index dbd8ba0..c8bcb5a 100644 --- a/unlock_indicator.c +++ b/unlock_indicator.c @@ -63,7 +63,7 @@ extern cairo_surface_t *img_slideshow[256]; extern int slideshow_image_count; extern int slideshow_interval; -unsigned long lastCheck = -1; +unsigned long lastCheck; /* Whether the image should be tiled. */ extern bool tile; @@ -581,6 +581,10 @@ static void colorgen_rgb(rgb_str_t *tmp, const char *src, rgb_t *dest) { } void init_colors_once(void) { + + /* initialize for slideshow time interval */ + lastCheck = (unsigned long)time(NULL); + rgba_str_t tmp; rgb_str_t tmp_rgb; @@ -688,7 +692,7 @@ xcb_pixmap_t draw_image(uint32_t *resolution) { /*update image according to the slideshow_interval*/ if (slideshow_image_count > 0) { unsigned long now = (unsigned long)time(NULL); - if (-1 == lastCheck || now - lastCheck >= slideshow_interval) { + if (img == NULL || now - lastCheck >= slideshow_interval) { img = img_slideshow[current_slideshow_index++]; if (current_slideshow_index >= slideshow_image_count) {