aboutsummaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorBert <ber.t@gmx.com>2011-02-17 11:04:58 +0100
committerBert <ber.t@gmx.com>2011-02-17 11:04:58 +0100
commitbcc70bd7cbcdf56e84984929d9f8c6f1776f2204 (patch)
tree4318505a206a6440cceccbb14cc9f6703c92e8d5 /main.c
parente0d08920657e8e5132a732c2f429243efa899ac1 (diff)
downloadnsxiv-bcc70bd7cbcdf56e84984929d9f8c6f1776f2204.tar.zst
Who needs threads to load thumbnails?
Diffstat (limited to 'main.c')
-rw-r--r--main.c20
1 files changed, 12 insertions, 8 deletions
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;
}
}