diff src/X_main.c @ 41:400b4b5db0dc

Working on animation
author Thinker K.F. Li <thinker@branda.to>
date Fri, 08 Aug 2008 21:34:53 +0800
parents db2aa914e14b
children e3295c07faa9
line wrap: on
line diff
--- a/src/X_main.c	Wed Aug 06 21:34:53 2008 +0800
+++ b/src/X_main.c	Fri Aug 08 21:34:53 2008 +0800
@@ -24,8 +24,8 @@
     redraw_man_t *rdman;
 };
 
-void test_motion(mbsec_t sec, mbusec_t usec,
-		 mbsec_t now_sec, mbusec_t now_usec,
+void test_motion(const mb_timeval_t *tmo,
+		 const mb_timeval_t *now,
 		 void *arg) {
     struct test_motion_data *data = (struct test_motion_data *)arg;
 
@@ -88,6 +88,7 @@
     fd_set rds;
     int nfds;
     struct timeval tmo;
+    mb_timeval_t mb_tmo;
     int r;
 
     XSelectInput(display, win, PointerMotionMask | ExposureMask);
@@ -104,14 +105,15 @@
 	    return;
 	}
 
-	r = mb_tman_next_timeout(tman,
-				 tmo.tv_sec, tmo.tv_usec,
-				 (mbsec_t *)&tmo.tv_sec,
-				 (mbusec_t *)&tmo.tv_usec);
+	MB_TIMEVAL_SET(&mb_tmo, tmo.tv_sec, tmo.tv_usec);
+	r = mb_tman_next_timeout(tman, &mb_tmo, &mb_tmo);
 	if(r != OK)
 	    r = select(nfds, &rds, NULL, NULL, NULL);
-	else
+	else {
+	    tmo.tv_sec = MB_TIMEVAL_SEC(&mb_tmo);
+	    tmo.tv_usec = MB_TIMEVAL_USEC(&mb_tmo);
 	    r = select(nfds, &rds, NULL, NULL, &tmo);
+	}
 
 	if(r == -1) {
 	    perror("select");
@@ -123,7 +125,8 @@
 		perror("gettimeofday");
 		return;
 	    }
-	    mb_tman_handle_timeout(tman, tmo.tv_sec, tmo.tv_usec);
+	    MB_TIMEVAL_SET(&mb_tmo, tmo.tv_sec, tmo.tv_usec);
+	    mb_tman_handle_timeout(tman, &mb_tmo);
 	    XFlush(display);
 	} else if(FD_ISSET(xcon, &rds)) {
 	    event_interaction(display, rdman, w, h);
@@ -145,6 +148,7 @@
     struct test_motion_data mdata;
     struct timeval tv;
     mb_tman_t *tman;
+    mb_timeval_t mbtv;
     int i;
 
     tmpsuf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h);
@@ -296,10 +300,11 @@
 	mdata.rdman = &rdman;
 	gettimeofday(&tv, NULL);
 	tv.tv_sec += 3;
-	mb_tman_timeout(tman, tv.tv_sec, tv.tv_usec,
-			test_motion, &mdata);
+	MB_TIMEVAL_SET(&mbtv, tv.tv_sec, tv.tv_usec);
+	mb_tman_timeout(tman, &mbtv, test_motion, &mdata);
 
 	handle_connection(display, tman, &rdman, w, h);
+
 	mb_tman_free(tman);
     }