On Sun, 5 Dec 1999, Maarten ter Huurne wrote:

> Hi!
> I have some questions about events. Either I misinterpreted the
> documentation, or they work differently than the documentation suggests.
> The first question is about event masks. I used ggiSetEventMask to receive
> only key press and release events. However, mouse events ("evPtrAbsolute"
> to be exact) still end up in the event queue.
> Here is a code fragment:
>   tv.tv_sec = 0;
>   tv.tv_usec = 0;
>   ggiSetEventMask(Vis, emKeyPress | emKeyRelease);
>   ggiEventPoll(Vis, emAll, &tv);
>   n = ggiEventsQueued(Vis, emAll);
>   while(n--) {
>     if (ggiEventRead(Vis, &evt, emAll)==0)
>       fprintf(stderr, "[error reading events]\n");
>     if(evt.any.type==evKeyPress) {
>       ...
> When the fragment above is executed, evt.any.type==evPtrAbsolute will
> occur. But I would expect mouse events to be filtered out since the
> ggiSetEventMask was called.
> Note: it's not events left in the buffer from before the ggiSetEventMask.
> The fragment is called about 10-100 times per second and after a few seconds
> mouse events still come in.

I have no idea; forwarding to mailing list...

> The other question: (about the same code fragment)
> Why I can't omit the call to ggiEventPoll?
> If the ggiEventQueued call is not preceded by a ggiEventPoll call, it
> always returns 0 ("0 events matching mask in queue"). Since the ggiEventPoll
> is called with a timeout of zero, I figured it wouldn't do anything really.
> But it seems it does some important internal administration.

Yes, ggiEventPoll() actually does "read" the events into the queue.
ggiEventRead() pulls the events from the queue.  (If there is none, it
calls blocking ggiEventPoll internally -- all documented in the source :)

I guess I should fix the documentation on that.

Steve Cheng

www: <http://shell.ipoline.com/~elmert/>

Reply via email to