Re: How to check X windows events

New Message Reply Date view Thread view Subject view Author view

Sharon Clay (src++at++rose)
Thu, 11 Jan 1996 11:34:59 -0800


+>---- On Jan 11, 5:58pm, Nuno Godinho wrote:
> Subject: How to check X windows events
->From guest++at++holodeck Thu Jan 11 09:53:57 1996
->Sender: mgo++at++minerva.inesc.pt
->Date: Thu, 11 Jan 1996 17:58:39 +0100
->From: Nuno Godinho <mgo++at++minerva.inesc.pt>
->X-Mailer: Mozilla 2.0b5 (X11; I; SunOS 4.1.3 sun4c)
->To: info-performer++at++sgi.sgi.com
->Subject: How to check X windows events
->
->I would like to know what's the best and fastest way to check mouse
->events in X.
->I don't seem to understand the code in the "complex-glx.c" example that
->comes with Performer 1.2.
->
->The "complex-glx.c" file uses the XCheckWindowEvent twice. The first
->time with glWin and GLINMASK as parameters. And the second time with
->xWin and XINMASK.

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++

New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:52:15 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.