From d5ef5bf962c99a56c38c854d8665cec9a0afff9d Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Sun, 9 Jun 2019 15:50:24 -0500 Subject: [PATCH] select() on X display fd to avoid needing timeout --- examples/cluster.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/examples/cluster.c b/examples/cluster.c index 41fe651..434f297 100644 --- a/examples/cluster.c +++ b/examples/cluster.c @@ -67,7 +67,7 @@ int main(int argc, char **argv) { hexagram_window *window; hexagram_cluster *cluster; - int fd, + int fd, fd2, width = 1024, height = 480; @@ -96,7 +96,8 @@ int main(int argc, char **argv) { display = hexagram_window_display(window); - fd = hexagram_can_if_fd(can_if); + fd = hexagram_can_if_fd(can_if); + fd2 = hexagram_window_display_fd(window); /* * Set up the rendering surfaces @@ -119,16 +120,14 @@ int main(int argc, char **argv) { */ FD_ZERO(&rfds); - FD_SET(fd, &rfds); + FD_SET(fd, &rfds); + FD_SET(fd2, &rfds); while (1) { - struct timeval timeout = { - .tv_sec = 0, - .tv_usec = 250000 - }, now; + struct timeval now; int pending, - nfds = fd + 1; + nfds = fd2 + 1; (void)gettimeofday(&now, NULL); @@ -157,7 +156,7 @@ int main(int argc, char **argv) { memcpy(&rready, &rfds, sizeof(rfds)); - if (select(nfds, &rready, NULL, NULL, &timeout) < 0) { + if (select(nfds, &rready, NULL, NULL, NULL) < 0) { break; }