This looks good, thanks! But I think you do need to go around the loop multiple times, because there's technically no guarantee that the response event we're polling for in XCheckIfEvent will be the first event to come in. There might be some event we don't care about that causes select() to return, and then the event we need comes in some fraction of a second later.
-- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org