fix the select() call to work after it has timed out, and always flush at the end...
authorDana Jansens <danakj@orodu.net>
Wed, 5 Mar 2008 01:09:35 +0000 (20:09 -0500)
committerDana Jansens <danakj@orodu.net>
Wed, 5 Mar 2008 01:10:14 +0000 (20:10 -0500)
dcompmgr.c

index f441f8a..d39b101 100644 (file)
@@ -136,12 +136,6 @@ static void
 run(d_display_t *dpy)
 {
     gboolean quit;
-    fd_set   fds;
-    int      max = -1;
-
-    FD_ZERO(&fds);
-    FD_SET(dpy->fd, &fds);
-    max = MAX(max, dpy->fd);
 
     paint(dpy);
 
@@ -150,6 +144,7 @@ run(d_display_t *dpy)
         struct timeval next, now, *wait;
         int            r, npaint;
         d_list_it_t   *it;
+        fd_set         fds;
 
         npaint = 0;
         for (it = list_top(dpy->screens); it; it = it->next) {
@@ -181,7 +176,10 @@ run(d_display_t *dpy)
             wait = &next;
         }
 
-        r = select(max+1, &fds, NULL, NULL, wait);
+        FD_ZERO(&fds);
+        FD_SET(dpy->fd, &fds);
+
+        r = select(dpy->fd+1, &fds, NULL, NULL, wait);
         if (r < 0)
             printf("select error\n");
         else if (r == 0) {
@@ -197,6 +195,8 @@ run(d_display_t *dpy)
 
         if (xcb_connection_has_error(dpy->conn))
             quit = TRUE;
+        else
+            xcb_flush(dpy->conn);
     }
 }