/* create a pixmap as large as the root window */ pix = XCreatePixmap (dpy, root, wa.width, wa.height, wa.depth);
/* clear the pixmap (not done by default) */ XSetForeground(dpy, g, WhitePixelOfScreen(DefaultScreenOfDisplay(dpy)) ); XFillRectangle (dpy, pix, g, 0, 0, wa.width, wa.height);
/* draw in the pixmap */ for(i=0; i<500; i++) { /* set a random foreground color */ XSetForeground(dpy, g, xcolors[random()%NCOLORS].pixel); /* draw a square */ XFillRectangle (dpy, pix, g, random()%(wa.width-50), random()%(wa.height-40), 50, 40); }
/* set the pixmap as the background of the root window */ XSetWindowBackgroundPixmap (dpy, root, pix);
/* clear the root window to make the pixmap visible */ XClearWindow (dpy, root);