next up previous contents
Next: Catching Motion Events Up: Programming Tips Previous: Avoiding multiple Exposure

Coping with Exposures

You will have to repair the damage made by occluding windows. Some options are

Display lists:-
keep a note of all graphics operations and replay them when necessary.

Backing Store:-
If your machine supports it (use xdpyinfo from the command line to find out) you could set this facility, but it will tie memory up.

Exposure Events:-
the event returns region affected, so you could just redraw this area. Eg, a chessboard could just have damaged squares redrawn.

Clipping using Regions:-
redraw only the damaged regions by clipping.
XEvent event;
Region region;
XRectangle rectangle;
switch(event.type){
     case Expose:
         region = XCreateRegion();
 
         /*Make the union of the rectangles into a  Region */
         do{
           rectangle.x = (short) event.xexpose.x
           rectangle.y = (short) event.xexpose.y
           rectangle.width = (unsigned short) event.xexpose.width
           rectangle.height = (unsigned short) event.xexpose.height
           XUnionRectWithRegion(&rectangle,region,region);
 
         } while(XCheckTypedEvent(display,Expose, &event);
          
         XSetRegion(display,gc,region);
         redraw(window);
         XDestroyRegion(region);
         break;


Tim Love
Mon Mar 11 17:03:18 GMT 1996