Immediately respond to events while loading thumbs
This commit is contained in:
parent
e2889ab891
commit
b828b55419
19
main.c
19
main.c
|
@ -22,6 +22,7 @@
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
@ -469,7 +470,7 @@ void on_motionnotify(XMotionEvent *mev) {
|
||||||
void run() {
|
void run() {
|
||||||
int xfd;
|
int xfd;
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
struct timeval t;
|
struct timeval t, t0;
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
|
||||||
timeout = 0;
|
timeout = 0;
|
||||||
|
@ -477,12 +478,22 @@ void run() {
|
||||||
while (1) {
|
while (1) {
|
||||||
if (mode == MODE_THUMBS && tns_loaded < filecnt) {
|
if (mode == MODE_THUMBS && tns_loaded < filecnt) {
|
||||||
win_set_cursor(&win, CURSOR_WATCH);
|
win_set_cursor(&win, CURSOR_WATCH);
|
||||||
tns_load(&tns, &win, filenames[tns_loaded++]);
|
gettimeofday(&t0, 0);
|
||||||
tns_render(&tns, &win);
|
|
||||||
|
while (!XPending(win.env.dpy) && tns_loaded < filecnt) {
|
||||||
|
tns_load(&tns, &win, filenames[tns_loaded++]);
|
||||||
|
gettimeofday(&t, 0);
|
||||||
|
if (TV_TO_DOUBLE(t) - TV_TO_DOUBLE(t0) >= 0.25)
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (tns_loaded == filecnt)
|
if (tns_loaded == filecnt)
|
||||||
win_set_cursor(&win, CURSOR_ARROW);
|
win_set_cursor(&win, CURSOR_ARROW);
|
||||||
else if (!XPending(win.env.dpy))
|
if (!XPending(win.env.dpy)) {
|
||||||
|
tns_render(&tns, &win);
|
||||||
continue;
|
continue;
|
||||||
|
} else {
|
||||||
|
timeout = 1;
|
||||||
|
}
|
||||||
} else if (timeout) {
|
} else if (timeout) {
|
||||||
t.tv_sec = 0;
|
t.tv_sec = 0;
|
||||||
t.tv_usec = 75000;
|
t.tv_usec = 75000;
|
||||||
|
|
2
thumbs.c
2
thumbs.c
|
@ -85,6 +85,8 @@ void tns_render(tns_t *tns, win_t *win) {
|
||||||
if (!tns || !win)
|
if (!tns || !win)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
printf("tns_render()\n");
|
||||||
|
|
||||||
tns->cols = win->w / thumb_dim;
|
tns->cols = win->w / thumb_dim;
|
||||||
tns->rows = win->h / thumb_dim;
|
tns->rows = win->h / thumb_dim;
|
||||||
|
|
||||||
|
|
3
util.h
3
util.h
|
@ -27,6 +27,9 @@
|
||||||
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||||
#define LEN(a) (sizeof(a) / sizeof(a[0]))
|
#define LEN(a) (sizeof(a) / sizeof(a[0]))
|
||||||
|
|
||||||
|
#define TV_TO_DOUBLE(x) ((double) ((x).tv_sec) + 0.000001 * \
|
||||||
|
(double) ((x).tv_usec))
|
||||||
|
|
||||||
void* s_malloc(size_t);
|
void* s_malloc(size_t);
|
||||||
void* s_realloc(void*, size_t);
|
void* s_realloc(void*, size_t);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue