From bcc70bd7cbcdf56e84984929d9f8c6f1776f2204 Mon Sep 17 00:00:00 2001 From: Bert Date: Thu, 17 Feb 2011 11:04:58 +0100 Subject: Who needs threads to load thumbnails? --- main.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 2fccf7a..ec770e6 100644 --- a/main.c +++ b/main.c @@ -54,6 +54,8 @@ const char **filenames; int filecnt, fileidx; size_t filesize; +int tns_loaded; + #define TITLE_LEN 256 char win_title[TITLE_LEN]; @@ -128,13 +130,13 @@ int main(int argc, char **argv) { win_open(&win); img_init(&img, &win); - if (options->thumbnails) - tns_load(&tns, &win, filenames, filecnt); + if (options->thumbnails) { + tns_loaded = 0; + tns_init(&tns, filecnt); + } if (options->thumbnails == 2) { mode = MODE_THUMBS; - tns.first = tns.sel = 0; - tns_render(&tns, &win); } else { mode = MODE_NORMAL; load_image(); @@ -473,7 +475,12 @@ void run() { timeout = 0; while (1) { - if (timeout || (mode == MODE_THUMBS && !tns.loaded)) { + if (mode == MODE_THUMBS && tns_loaded < filecnt) { + tns_load(&tns, &win, filenames[tns_loaded++]); + tns_render(&tns, &win); + if (!XPending(win.env.dpy)) + continue; + } else if (timeout) { t.tv_sec = 0; t.tv_usec = 250; xfd = ConnectionNumber(win.env.dpy); @@ -486,9 +493,6 @@ void run() { img_render(&img, &win); else tns_render(&tns, &win); - - if (mode == MODE_THUMBS && !tns.loaded && !XPending(win.env.dpy)) - continue; } } -- cgit v1.2.3-54-g00ecf