Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!usc!ucsd!ucbvax!bloom-beacon!SABER.COM!jimf From: jimf@SABER.COM Newsgroups: comp.windows.x Subject: Re: How Do You Monitor Events For More Than 1 Display? Message-ID: <9012031508.AA01432@armory> Date: 3 Dec 90 15:08:03 GMT Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 42 |I am writing this program which is supposed to wait for KeyPress |events from more than 1 display, however, after thinking about |it for a long long time, I don't really know how to do it. |Please enlighten me. You should use select, something like this: #include #include fd_set readfds; FD_ZERO(&readfds); FS_SET(ConnectionNumber(display1), &readfds); FS_SET(ConnectionNumber(display2), &readfds); for (;;) { switch(select(dtablesize(), &readfds, NULL, NULL, NULL)) { case -1: if (errno == EINTR) continue; perror("select"); exit(1); case 0: continue; default: if (FD_ISSET(ConnectionNumber(display1), &readfds)) { while (XPending(display1)) XNextEvent(display1, &event); /* do your thing here */ } if (FD_ISSET(ConnectionNumber(display2), &readfds)) { while (XPending(display1)) XNextEvent(display1, &event); /* do your thing here */ } } } jim frost saber software jimf@saber.com