Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!sun!frisbee!jcb From: jcb@frisbee.Sun.COM (Jim Becker) Newsgroups: comp.windows.x Subject: Re: Browsing Event Queue Message-ID: <142429@sun.Eng.Sun.COM> Date: 13 Sep 90 22:07:00 GMT References: <9009121836.AA16685@ATHENA.MIT.EDU> Sender: news@sun.Eng.Sun.COM Lines: 82 Jean-Christophe.Dhellemmes@MAPS.CS.CMU.EDU writes: I would like to be able to browse through the entire event queue in my refresh loop and interrupt the refresh loop if an expose or resize event is in the queue. - Is there an official way to do what I need (like getting a pointer to the event queue) ? I've had need to do the same sort of thing. Wanted to avoid doing exposure processing if there are more exposure events in the incoming queue. Didn't find anything efficient and suitable in the Xlib grabbag. - Is there another method ? Yes, look at the events that hang off the display event list. Note that this isn't really legal, but I haven't yet had problems with it. The same sort of code within the Xlib itself does calls to lock and unlock the display, but on Suns (last time I checked) they were noops. Here is some code that can be used to scan the list: /* * 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; } in the event processing I do this sort of logic: switch( xevent.type ) { ... case Expose: /* only do the last one in the queue */ if( no_more_expose( display, xevent.xany.window ) ) repaint_window( args ); break; ... } It's not directly legal, but filled a void I found in my needs. One can get more exotic additionally, in that flushing and event queue reading can be added to the scan logic. (This is used for best assurance that there is nothing pending on the wire.) The example posted is the simple case. -Jim -- Jim Becker / jcb%frisbee@sun.com / Sun Microsystems