All timeouts in milliseconds
This commit is contained in:
		
							parent
							
								
									f52603b31a
								
							
						
					
					
						commit
						bd87ae9346
					
				
							
								
								
									
										2
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Makefile
									
									
									
									
									
								
							| @ -1,6 +1,6 @@ | |||||||
| all: sxiv | all: sxiv | ||||||
| 
 | 
 | ||||||
| VERSION = git-20110624 | VERSION = git-20110628 | ||||||
| 
 | 
 | ||||||
| CC = gcc | CC = gcc | ||||||
| DESTDIR = | DESTDIR = | ||||||
|  | |||||||
							
								
								
									
										18
									
								
								main.c
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								main.c
									
									
									
									
									
								
							| @ -241,7 +241,7 @@ int main(int argc, char **argv) { | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	filecnt = fileidx; | 	filecnt = fileidx; | ||||||
| 	fileidx = options->startnum < filecnt ? options->startnum : filecnt - 1; | 	fileidx = options->startnum < filecnt ? options->startnum : 0; | ||||||
| 
 | 
 | ||||||
| 	win_init(&win); | 	win_init(&win); | ||||||
| 	img_init(&img, &win); | 	img_init(&img, &win); | ||||||
| @ -327,10 +327,11 @@ int run_command(const char *cline, Bool reload) { | |||||||
| 
 | 
 | ||||||
| /* event handling */ | /* event handling */ | ||||||
| 
 | 
 | ||||||
| #define TO_WIN_RESIZE  75000 | /* timeouts in milliseconds: */ | ||||||
| #define TO_IMAGE_DRAG  1000 | #define TO_WIN_RESIZE  75 | ||||||
| #define TO_CURSOR_HIDE 1500000 | #define TO_IMAGE_DRAG  1 | ||||||
| #define TO_THUMBS_LOAD 75000 | #define TO_CURSOR_HIDE 1500 | ||||||
|  | #define TO_THUMBS_LOAD 200 | ||||||
| 
 | 
 | ||||||
| int timo_cursor; | int timo_cursor; | ||||||
| int timo_redraw; | int timo_redraw; | ||||||
| @ -723,7 +724,7 @@ void run() { | |||||||
| 				else | 				else | ||||||
| 					remove_file(tns.cnt, 0); | 					remove_file(tns.cnt, 0); | ||||||
| 				gettimeofday(&t1, 0); | 				gettimeofday(&t1, 0); | ||||||
| 				if (TV_TO_DOUBLE(t1) - TV_TO_DOUBLE(t0) >= 0.25) | 				if (TIMEDIFF(&t1, &t0) >= TO_THUMBS_LOAD) | ||||||
| 					break; | 					break; | ||||||
| 			} | 			} | ||||||
| 			if (tns.cnt == filecnt) | 			if (tns.cnt == filecnt) | ||||||
| @ -742,8 +743,7 @@ void run() { | |||||||
| 				timeout = timo_cursor; | 				timeout = timo_cursor; | ||||||
| 			else | 			else | ||||||
| 				timeout = timo_redraw; | 				timeout = timo_redraw; | ||||||
| 			tt.tv_sec = timeout / 1000000; | 			MSEC_TO_TIMEVAL(timeout, &tt); | ||||||
| 			tt.tv_usec = timeout % 1000000; |  | ||||||
| 			xfd = ConnectionNumber(win.env.dpy); | 			xfd = ConnectionNumber(win.env.dpy); | ||||||
| 			FD_ZERO(&fds); | 			FD_ZERO(&fds); | ||||||
| 			FD_SET(xfd, &fds); | 			FD_SET(xfd, &fds); | ||||||
| @ -751,7 +751,7 @@ void run() { | |||||||
| 			if (!XPending(win.env.dpy)) | 			if (!XPending(win.env.dpy)) | ||||||
| 				select(xfd + 1, &fds, 0, 0, &tt); | 				select(xfd + 1, &fds, 0, 0, &tt); | ||||||
| 			gettimeofday(&t1, 0); | 			gettimeofday(&t1, 0); | ||||||
| 			timeout = MIN((TV_TO_DOUBLE(t1) - TV_TO_DOUBLE(t0)) * 1000000, timeout); | 			timeout = MIN(TIMEDIFF(&t1, &t0), timeout); | ||||||
| 
 | 
 | ||||||
| 			/* timeouts fired? */ | 			/* timeouts fired? */ | ||||||
| 			if (timo_cursor) { | 			if (timo_cursor) { | ||||||
|  | |||||||
							
								
								
									
										11
									
								
								util.h
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								util.h
									
									
									
									
									
								
							| @ -28,13 +28,20 @@ | |||||||
| #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 * \ | #define TIMEDIFF(t1,t2) (((t1)->tv_sec - (t2)->tv_sec) * 1000 +  \ | ||||||
|                          (double) ((x).tv_usec)) |                          ((t1)->tv_usec - (t2)->tv_usec) / 1000) | ||||||
| 
 | 
 | ||||||
|  | #define MSEC_TO_TIMEVAL(t,tv) {         \ | ||||||
|  |   (tv)->tv_sec = (t) / 1000;            \ | ||||||
|  | 	(tv)->tv_usec = (t) % 1000 * 1000;    \ | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #ifndef TIMESPEC_TO_TIMEVAL | ||||||
| #define TIMESPEC_TO_TIMEVAL(tv,ts) {    \ | #define TIMESPEC_TO_TIMEVAL(tv,ts) {    \ | ||||||
|   (tv)->tv_sec = (ts)->tv_sec;          \ |   (tv)->tv_sec = (ts)->tv_sec;          \ | ||||||
|   (tv)->tv_usec = (ts)->tv_nsec / 1000; \ |   (tv)->tv_usec = (ts)->tv_nsec / 1000; \ | ||||||
| } | } | ||||||
|  | #endif | ||||||
| 
 | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
| 	DIR *dir; | 	DIR *dir; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Bert
						Bert