select() on X display fd to avoid needing timeout

This commit is contained in:
XANTRONIX Development 2019-06-09 15:50:24 -05:00
parent 0299922b88
commit d5ef5bf962

View file

@ -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;
}