nsxivdcd04e5
Corrected thumbnail loading and timeout handling
+21 −21
1 file changed
- M main.c +21 −21
| @@ -357,31 +357,31 @@ void run() { | |||
| 357 | 357 | redraw(); | |
| 358 | 358 | ||
| 359 | 359 | while (1) { | |
| 360 | − | if (!XPending(win.env.dpy)) { | |
| 360 | + | while (mode == MODE_THUMB && tns.cnt < filecnt && | |
| 361 | + | !XPending(win.env.dpy)) | |
| 362 | + | { | |
| 361 | 363 | /* 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); | |
| 375 | 375 | } | |
| 376 | + | } | |
| 376 | 377 | ||
| 378 | + | if (!XPending(win.env.dpy) && check_timeouts(&timeout)) { | |
| 377 | 379 | /* 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); | |
| 385 | 385 | } | |
| 386 | 386 | ||
| 387 | 387 | if (!XNextEvent(win.env.dpy, &ev)) { | |