Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!apple!sun-barr!newstop!exodus!frisbee.Eng.Sun.COM!jcb From: jcb@frisbee.Eng.Sun.COM (Jim Becker) Newsgroups: comp.windows.open-look Subject: Re: looking ahead in X event queue Message-ID: <6404@exodus.Eng.Sun.COM> Date: 22 Jan 91 21:28:53 GMT References: Sender: news@exodus.Eng.Sun.COM Lines: 59 wolinsky%isys@uunet.UU.NET (Jeff Wolinsky) writes: It would be VERY useful if I could look ahead in my event queue with the following conditions: (1) If the specific event isn't found, it shouldn't wait. (2) If the event is found, it should be left in its postion in the queue. I know that XCheckIfEvent() satisfies condition 1 but not 2, whereas XPeekIfEvent() satisfies 2 but not 1. Other than pulling every event off the queue and XPutBackEvent() when I'm done, any suggestions? You can look into the queue yourself, but this isn't supported, advised or approved by official channels. If you want to look into the queue for events, here is an example of how it can be done. Note that there are also things one can do to force flushing and such, but this is the basic example of how to get in there. This looks for expose events, and returns boolean. /* * poke down the queue to see if there are more expose events * this looks down the display event queue to see if there is * another event that is of the exposure type. the content of * the queue is not disturbed. somewhat questionable, but there * is no mechanism that doesn't disturb the queue in Xlib. */ no_more_expose( display, window ) Display *display; Window window; { struct _XSQEvent *qevent; Window ewin; int etype; short found = FALSE; for( qevent = display->head; qevent != NULL && !found; qevent = qevent->next ) { etype = qevent->event.xany.type; ewin = qevent->event.xany.window; found = ((etype == Expose) || (etype == GraphicsExpose)) && (ewin == window); } return !found; } -Jim -- -- Jim Becker / jcb%frisbee@sun.com / Sun Microsystems