| @@ -22,6 +22,7 @@ |
| 22 | 22 | | #include <dirent.h> |
| 23 | 23 | | #include <sys/select.h> |
| 24 | 24 | | #include <sys/stat.h> |
| 25 | + | #include <sys/time.h> |
| 25 | 26 | | |
| 26 | 27 | | #include <X11/Xlib.h> |
| 27 | 28 | | #include <X11/Xutil.h> |
| @@ -469,7 +470,7 @@ void on_motionnotify(XMotionEvent *mev) { |
| 469 | 470 | | void run() { |
| 470 | 471 | | int xfd; |
| 471 | 472 | | fd_set fds; |
| 472 | | − | struct timeval t; |
| 473 | + | struct timeval t, t0; |
| 473 | 474 | | XEvent ev; |
| 474 | 475 | | |
| 475 | 476 | | timeout = 0; |
| @@ -477,12 +478,22 @@ void run() { |
| 477 | 478 | | while (1) { |
| 478 | 479 | | if (mode == MODE_THUMBS && tns_loaded < filecnt) { |
| 479 | 480 | | win_set_cursor(&win, CURSOR_WATCH); |
| 480 | | − | tns_load(&tns, &win, filenames[tns_loaded++]); |
| 481 | | − | tns_render(&tns, &win); |
| 481 | + | gettimeofday(&t0, 0); |
| 482 | + | |
| 483 | + | while (!XPending(win.env.dpy) && tns_loaded < filecnt) { |
| 484 | + | tns_load(&tns, &win, filenames[tns_loaded++]); |
| 485 | + | gettimeofday(&t, 0); |
| 486 | + | if (TV_TO_DOUBLE(t) - TV_TO_DOUBLE(t0) >= 0.25) |
| 487 | + | break; |
| 488 | + | } |
| 482 | 489 | | if (tns_loaded == filecnt) |
| 483 | 490 | | win_set_cursor(&win, CURSOR_ARROW); |
| 484 | | − | else if (!XPending(win.env.dpy)) |
| 491 | + | if (!XPending(win.env.dpy)) { |
| 492 | + | tns_render(&tns, &win); |
| 485 | 493 | | continue; |
| 494 | + | } else { |
| 495 | + | timeout = 1; |
| 496 | + | } |
| 486 | 497 | | } else if (timeout) { |
| 487 | 498 | | t.tv_sec = 0; |
| 488 | 499 | | t.tv_usec = 75000; |