Krolyxon
Commit bd87ae9

Branches

Refs →

nsxivbd87ae9

All timeouts in milliseconds

Author
Bert
Date
2011-06-28 13:45 +0200
Parent
f52603b
Commit
bd87ae9346503cb13ab1d12ff6f135b77fa0b473

+22 −15

3 files changed

  1. M Makefile +1 −1
  2. M main.c +9 −9
  3. M util.h +12 −5
M Makefile View
@@ -1,6 +1,6 @@
11 all: sxiv
22
3−VERSION = git-20110624
3+VERSION = git-20110628
44
55 CC = gcc
66 DESTDIR =
M main.c View
@@ -241,7 +241,7 @@ int main(int argc, char **argv) {
241241 }
242242
243243 filecnt = fileidx;
244− fileidx = options->startnum < filecnt ? options->startnum : filecnt - 1;
244+ fileidx = options->startnum < filecnt ? options->startnum : 0;
245245
246246 win_init(&win);
247247 img_init(&img, &win);
@@ -327,10 +327,11 @@ int run_command(const char *cline, Bool reload) {
327327
328328 /* event handling */
329329
330−#define TO_WIN_RESIZE 75000
331−#define TO_IMAGE_DRAG 1000
332−#define TO_CURSOR_HIDE 1500000
333−#define TO_THUMBS_LOAD 75000
330+/* timeouts in milliseconds: */
331+#define TO_WIN_RESIZE 75
332+#define TO_IMAGE_DRAG 1
333+#define TO_CURSOR_HIDE 1500
334+#define TO_THUMBS_LOAD 200
334335
335336 int timo_cursor;
336337 int timo_redraw;
@@ -723,7 +724,7 @@ void run() {
723724 else
724725 remove_file(tns.cnt, 0);
725726 gettimeofday(&t1, 0);
726− if (TV_TO_DOUBLE(t1) - TV_TO_DOUBLE(t0) >= 0.25)
727+ if (TIMEDIFF(&t1, &t0) >= TO_THUMBS_LOAD)
727728 break;
728729 }
729730 if (tns.cnt == filecnt)
@@ -742,8 +743,7 @@ void run() {
742743 timeout = timo_cursor;
743744 else
744745 timeout = timo_redraw;
745− tt.tv_sec = timeout / 1000000;
746− tt.tv_usec = timeout % 1000000;
746+ MSEC_TO_TIMEVAL(timeout, &tt);
747747 xfd = ConnectionNumber(win.env.dpy);
748748 FD_ZERO(&fds);
749749 FD_SET(xfd, &fds);
@@ -751,7 +751,7 @@ void run() {
751751 if (!XPending(win.env.dpy))
752752 select(xfd + 1, &fds, 0, 0, &tt);
753753 gettimeofday(&t1, 0);
754− timeout = MIN((TV_TO_DOUBLE(t1) - TV_TO_DOUBLE(t0)) * 1000000, timeout);
754+ timeout = MIN(TIMEDIFF(&t1, &t0), timeout);
755755
756756 /* timeouts fired? */
757757 if (timo_cursor) {
M util.h View
@@ -28,14 +28,21 @@
2828 #define MAX(a,b) ((a) > (b) ? (a) : (b))
2929 #define LEN(a) (sizeof(a) / sizeof(a[0]))
3030
31−#define TV_TO_DOUBLE(x) ((double) ((x).tv_sec) + 0.000001 * \
32− (double) ((x).tv_usec))
31+#define TIMEDIFF(t1,t2) (((t1)->tv_sec - (t2)->tv_sec) * 1000 + \
32+ ((t1)->tv_usec - (t2)->tv_usec) / 1000)
3333
34−#define TIMESPEC_TO_TIMEVAL(tv, ts) { \
35− (tv)->tv_sec = (ts)->tv_sec; \
36− (tv)->tv_usec = (ts)->tv_nsec / 1000; \
34+#define MSEC_TO_TIMEVAL(t,tv) { \
35+ (tv)->tv_sec = (t) / 1000; \
36+ (tv)->tv_usec = (t) % 1000 * 1000; \
3737 }
3838
39+#ifndef TIMESPEC_TO_TIMEVAL
40+#define TIMESPEC_TO_TIMEVAL(tv,ts) { \
41+ (tv)->tv_sec = (ts)->tv_sec; \
42+ (tv)->tv_usec = (ts)->tv_nsec / 1000; \
43+}
44+#endif
45+
3946 typedef struct {
4047 DIR *dir;
4148 char *name;