Krolyxon
Commit dcd04e5

Branches

Refs →

nsxivdcd04e5

Corrected thumbnail loading and timeout handling

Author
Bert
Date
2011-09-02 15:56 +0200
Parent
1e84773
Commit
dcd04e526d8d4382f6a26534897901d882d43526

+21 −21

1 file changed

  1. M main.c +21 −21
M main.c View
@@ -357,31 +357,31 @@ void run() {
357357 redraw();
358358
359359 while (1) {
360− if (!XPending(win.env.dpy)) {
360+ while (mode == MODE_THUMB && tns.cnt < filecnt &&
361+ !XPending(win.env.dpy))
362+ {
361363 /* load thumbnails */
362− while (mode == MODE_THUMB && tns.cnt < filecnt) {
363− win_set_cursor(&win, CURSOR_WATCH);
364− if (tns_load(&tns, tns.cnt, &files[tns.cnt], False, False))
365− tns.cnt++;
366− else
367− remove_file(tns.cnt, 0);
368− if (tns.cnt == filecnt) {
369− redraw();
370− win_set_cursor(&win, CURSOR_ARROW);
371− } else {
372− set_timeout(redraw, TO_REDRAW_THUMBS, 0);
373− check_timeouts(NULL);
374− }
364+ win_set_cursor(&win, CURSOR_WATCH);
365+ set_timeout(redraw, TO_REDRAW_THUMBS, 0);
366+ if (tns_load(&tns, tns.cnt, &files[tns.cnt], False, False))
367+ tns.cnt++;
368+ else
369+ remove_file(tns.cnt, 0);
370+ if (tns.cnt == filecnt) {
371+ redraw();
372+ win_set_cursor(&win, CURSOR_ARROW);
373+ } else {
374+ check_timeouts(NULL);
375375 }
376+ }
376377
378+ if (!XPending(win.env.dpy) && check_timeouts(&timeout)) {
377379 /* handle timeouts */
378− if (check_timeouts(&timeout)) {
379− xfd = ConnectionNumber(win.env.dpy);
380− FD_ZERO(&fds);
381− FD_SET(xfd, &fds);
382− if (!select(xfd + 1, &fds, 0, 0, &timeout))
383− check_timeouts(NULL);
384− }
380+ xfd = ConnectionNumber(win.env.dpy);
381+ FD_ZERO(&fds);
382+ FD_SET(xfd, &fds);
383+ if (!select(xfd + 1, &fds, 0, 0, &timeout))
384+ check_timeouts(NULL);
385385 }
386386
387387 if (!XNextEvent(win.env.dpy, &ev)) {