[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Xlib and file descriptors

Lutz Sammer wrote:

> > Speaking of file descriptors, does anybody know of a way to get the fd
> > of the connection to the X server or at least a "pseudo-select" (like
> > Svgalib has)?
> >
> > I'd like my game to be totally blocking on the poll/select call, with
> > everything expressed as file descriptors and with the timeout set for my
> > timebase (if poll returns after a timeout, I send a timetick event and
> > go back into the poll)...
> You can get it with ConnectionNumber. (man ConnectionNumber)

Thanks a lot! Talk about documentation:

        The ConnectionNumber macro returns a connection number for
        the specified display.

That's an fd? :-)

> To get a constant timing base, use setitimer. This is also works fine
> combined with select/poll.

Yes, but this introduces signals in the equation, with all the
restrictions of what you can and can't do in the signal handler. I do
extensive stuff upon getting the timetick event, so I'd have to set a
flag somewhere and check it in my event loop anyway, which would be too
late in this case.

Pierre Phaneuf
Ludus Design, http://ludusdesign.com/
"First they ignore you. Then they laugh at you.
Then they fight you. Then you win." -- Gandhi