Waiting on a file descriptor?

Is there a generally-accepted way to wait for I/O on a file descriptor in
SDL? (X11/UNIX only, obviously)

I can’t just check the descriptor repeatedly; I need true multiplexed
blocking behavior. (and no, I am not going to fork another thread just to
read the FD).

I was thinking about performing my own select() on all relevant fd’s, then
dropping into SDL_PollEvent() when something comes in from the X socket. But
to set this up I need the Display* that my program is using (for
XConnectionNumber) – how can I obtain it?

Regards,
Dan

Is there a generally-accepted way to wait for I/O on a file descriptor in
SDL? (X11/UNIX only, obviously)

I can’t just check the descriptor repeatedly; I need true multiplexed
blocking behavior. (and no, I am not going to fork another thread just to
read the FD).

I was thinking about performing my own select() on all relevant fd’s, then
dropping into SDL_PollEvent() when something comes in from the X socket. But
to set this up I need the Display* that my program is using (for
XConnectionNumber) – how can I obtain it?

You can use the SDL_syswm.h interfaces.
An example is in the FAQ:
http://www.libsdl.org/faq/FAQ-Linux.html#LINUX_13

Remember that there are other internal SDL events that happen besides those
that occur on the X11 file descriptor. You’ll probably be okay doing things
the way you describe, but do keep that in mind.

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software