void drawRectangles(Rectangle[] rects, boolean stippled) {
   int xDisplay = display.xDisplay;
   int color = OS.XWhitePixel(xDisplay, 0);
   int xWindow = OS.XDefaultRootWindow(xDisplay);
   if (parent != null) {
     xWindow = OS.XtWindow(parent.handle);
     if (xWindow == 0) return;
     int foreground = parent.getForegroundPixel();
     Control control = parent.findBackgroundControl();
     if (control == null) control = parent;
     int background = control.getBackgroundPixel();
     color = foreground ^ background;
   }
   int gc = OS.XCreateGC(xDisplay, xWindow, 0, null);
   OS.XSetForeground(xDisplay, gc, color);
   OS.XSetSubwindowMode(xDisplay, gc, OS.IncludeInferiors);
   OS.XSetFunction(xDisplay, gc, OS.GXxor);
   int stipplePixmap = 0;
   if (stippled) {
     byte[] bits = {-86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0};
     stipplePixmap = OS.XCreateBitmapFromData(xDisplay, xWindow, bits, 8, 8);
     OS.XSetStipple(xDisplay, gc, stipplePixmap);
     OS.XSetFillStyle(xDisplay, gc, OS.FillStippled);
     OS.XSetLineAttributes(xDisplay, gc, 3, OS.LineSolid, OS.CapButt, OS.JoinMiter);
   }
   for (int i = 0; i < rects.length; i++) {
     Rectangle rect = rects[i];
     OS.XDrawRectangle(xDisplay, xWindow, gc, rect.x, rect.y, rect.width, rect.height);
   }
   if (stippled) {
     OS.XFreePixmap(xDisplay, stipplePixmap);
   }
   OS.XFreeGC(xDisplay, gc);
 }