[comp.windows.x] Configure/Expose event ordering.

bradley@dsl.cis.upenn.edu (John Bradley) (10/22/87)

I'm writing a *very* simple-minded program that merely displays some crap in
a window, and when you click the mouse in it, it goes away.  It also has to
keep the window contents accurate when it's exposed, or re-sized.

My problem is this.  I've set the event mask to "ButtonPressMask | ExposureMask
   | StructureNotifyMask".  In my main loop I simply check for those three
events.  Everything works well until I re-size the window (via uwm).  When I
do, I get an ExposeEvent, followed by a Configure and another Expose.  This
causes the program to redraw the contents of the window twice, the first time
scaled wrong.

My question is:  "Why do I get the first Expose event?"  Should I peek ahead
for a Configure event whenever I get an Expose, and if so, don't bother
redrawing?  Seems unclean.  

Suggestions gleefully accepted.

John Bradley  -  University of Pennsylvania

RWS@ZERMATT.LCS.MIT.EDU (Robert Scheifler) (10/22/87)

    Date: 21 Oct 87 22:23:49 GMT
    From: super.upenn.edu!dsl.cis.upenn.edu!bradley@rutgers.edu  (John Bradley)

	     Everything works well until I re-size the window (via uwm).  When I
    do, I get an ExposeEvent, followed by a Configure and another Expose.  This
    causes the program to redraw the contents of the window twice, the first time
    scaled wrong.

uwm puts up this little popup right over your window.  When uwm unmaps it, you
get the first exposure.  If the servers implemented save-unders, this wouldn't
be a problem.  If anyone would like to contribute public save-under and/or
backing-store code ...

swick@ATHENA.MIT.EDU (Ralph R. Swick) (10/22/87)

    Date: 21 Oct 87 22:23:49 GMT
    From: super.upenn.edu!dsl.cis.upenn.edu!bradley@rutgers.edu  (John Bradley)

                   I've set the event mask to "ButtonPressMask | ExposureMask
       | StructureNotifyMask".  In my main loop I simply check for those three
    events.  Everything works well until I re-size the window (via uwm).  When I
    do, I get an ExposeEvent, followed by a Configure and another Expose.  This
    causes the program to redraw the contents of the window twice, the first time
    scaled wrong.

The first Expose comes from the un-mapping of uwm's resize pop-up window.
You could discover this by examining the bounds of the region in the event.
For purposes of uwm, this should be fixed as soon as save-unders are
implemented.  However, for general simple-minded clients that ignore the
region information in exposure events (and repaint their entire window),
it may be desireable to look ahead in the event queue for more exposures
(with XCheck*Event) before processing the current one.  Such clients can,
of course, ignore all exposure events with count>0.