select() on X display fd to avoid needing timeout
This commit is contained in:
parent
0299922b88
commit
d5ef5bf962
1 changed files with 8 additions and 9 deletions
|
@ -67,7 +67,7 @@ int main(int argc, char **argv) {
|
||||||
hexagram_window *window;
|
hexagram_window *window;
|
||||||
hexagram_cluster *cluster;
|
hexagram_cluster *cluster;
|
||||||
|
|
||||||
int fd,
|
int fd, fd2,
|
||||||
width = 1024,
|
width = 1024,
|
||||||
height = 480;
|
height = 480;
|
||||||
|
|
||||||
|
@ -96,7 +96,8 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
display = hexagram_window_display(window);
|
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
|
* Set up the rendering surfaces
|
||||||
|
@ -119,16 +120,14 @@ int main(int argc, char **argv) {
|
||||||
*/
|
*/
|
||||||
FD_ZERO(&rfds);
|
FD_ZERO(&rfds);
|
||||||
|
|
||||||
FD_SET(fd, &rfds);
|
FD_SET(fd, &rfds);
|
||||||
|
FD_SET(fd2, &rfds);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
struct timeval timeout = {
|
struct timeval now;
|
||||||
.tv_sec = 0,
|
|
||||||
.tv_usec = 250000
|
|
||||||
}, now;
|
|
||||||
|
|
||||||
int pending,
|
int pending,
|
||||||
nfds = fd + 1;
|
nfds = fd2 + 1;
|
||||||
|
|
||||||
(void)gettimeofday(&now, NULL);
|
(void)gettimeofday(&now, NULL);
|
||||||
|
|
||||||
|
@ -157,7 +156,7 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
memcpy(&rready, &rfds, sizeof(rfds));
|
memcpy(&rready, &rfds, sizeof(rfds));
|
||||||
|
|
||||||
if (select(nfds, &rready, NULL, NULL, &timeout) < 0) {
|
if (select(nfds, &rready, NULL, NULL, NULL) < 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue