Listing 3

#define WIDTH     400
#define HEIGHT    300
#define MAX_RECTS       100

XRectangle      rectangles[ MAX_RECTS + 1 ];
Display         *display;
Window          window;
int                     number_rectangles, i;

/*
 * Set up some rectangles
 */
i = 0;
for ( x = 0; x < WIDTH; x += 50 )
       {
       for( y = 0; y < HEIGHT; y += 50 )
              {
              i++;

              if ( i >= MAX_RECTS )
                     {
                     i = MAX_RECTS - 1;
                     }

              rectangles[i].width  = 45;
              rectangles[i].height = 45;

              rectangles[i].x = x;
              rectangles[i].y = y;
              }

       }

/*
 * Make our window's shape be the set of rectangles
 */
number_rectangles = i;
XShapeCombineRectangles( display,
       window,
       ShapeBounding,
       0, 0,           /* x, y, offsets */
       rectangles,
       number_rectangles,
       ShapeSet,
       Unsorted );  /* we haven't sorted the rects */

/* End of File */