Sharon Clay (src++at++rose)
Thu, 11 Jan 1996 11:34:59 -0800
Actually, complex-glx.c wasn't really a great example of efficiency.
For the basic catching of events I typicall do:
if (XEventsQueued(dsp, QueuedAfterFlush))
while (XEventsQueued(dsp, QueuedAlready))
{
XEvent event;
XNextEvent(dsp, &event);
switch (event.type)
{
}
}
This gets all the events currently in your local queue and does only one
flush at the begining to get the events X has in its buffer.
You can do this once a frame without being too impacted.
It is good to be able to have your X event handling done in a
separate process (or even separate program) so that your real-time
processes are never explicitly waiting on X.
In your X input handler process you can wrap the above with:
while (1)
{
XEvent event;
if (XPeekEvent(dsp, &event))
GetXInput(dsp);
}
This will put the X input process to sleep if there are no pending events.
You can use a shared memory structure (from the main arena or in a pfDataPool)
to communicate between the event process and your main application.
You want to avoid having your main application collide on locks with your
X input process so grab the events from X into a separate buffer and then
quickly copy them into a buffer for the application to grab when it is ready.
This is what the libpfutil X input handling does.
I try to avoid catching Motion events if at all possibly and if I
do catch them, I throw out all but the last one in a stream as I pull them out
of the X event queue.
src.
--
-----{-----{---++at++ -----{----{---++at++ -----{----{---++at++ -----{----{---++at++
Sharon Rose Clay (Fischler) - Silicon Graphics, Advanced Systems Dev.
src++at++sgi.com (415) 933 - 1002 FAX: (415) 965 - 2658 MS 8U-590
-----{-----{---++at++ -----{----{---++at++ -----{----{---++at++ -----{----{---++at++
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:52:15 PDT