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);
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) {
gettimeofday(&now, 0);
- printf("* loop paint %d *\n", npaint);
-
if (!npaint)
/* wait forever, there is nothing that needs drawing */
wait = NULL;
else {
/* don't wait cuz a redraw is due now already */
next.tv_sec = 0;
- next.tv_usec = 1;
+ next.tv_usec = 0;
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) {
if (xcb_connection_has_error(dpy->conn))
quit = TRUE;
+ else
+ xcb_flush(dpy->conn);
}
}