#include /* This program demonstrates that the EXA implementation of PolyFillRect is unable to do tiled fills with 1 pixel wide tiles. It creates a window, and a 1x25 pixmap tile on which a vertical gradient is drawn. A 64x25 pixmap is then created, which is filled with the tile. The window is then mapped, and the pixmap is drawn in the upper-left corner of the window. The original tile is drawn 10 pixels to the right of the pixmap for reference. Note that this program as written only works with 24/32 bit TrueColor visuals. */ int main (int argc, char **argv) { int tilew = 1; int tileh = 25; int pixmapw = 64; int pixmaph = 25; int i; Display *dpy = XOpenDisplay (0); Window win = XCreateSimpleWindow (dpy, DefaultRootWindow (dpy), 0, 0, 256, 256, 0, 0, 0); /* Create the tile */ Pixmap tile = XCreatePixmap (dpy, win, tilew, tileh, DefaultDepth (dpy, DefaultScreen (dpy))); GC gc = XCreateGC (dpy, tile, 0, 0); /* Fill it with a vertical gradient (black -> blue) */ for (i = 0; i < tileh; i++) { XSetForeground (dpy, gc, 255 / tileh * i); XFillRectangle (dpy, tile, gc, 0, i, tilew, 1); } /* Create a pixmap to fill the tile with */ Pixmap pix = XCreatePixmap (dpy, win, pixmapw, pixmaph, DefaultDepth(dpy, DefaultScreen (dpy))); /* * Clear the destination pixmap to red first to verify that * something is written to it when doing the tiled fill. */ XSetForeground (dpy, gc, 0x00ff0000); XFillRectangle (dpy, pix, gc, 0, 0, pixmapw, pixmaph); /* Do the tiled fill */ XSetTile (dpy, gc, tile); XSetFillStyle (dpy, gc, FillTiled); XSetTSOrigin (dpy, gc, 0, 0); XFillRectangle (dpy, pix, gc, 0, 0, pixmapw, pixmaph); XSelectInput (dpy, win, ExposureMask); XMapWindow (dpy, win); while (1) { XEvent event; XNextEvent (dpy, &event); if (event.type == Expose) { /* Copy the pixmap contents to the window */ XCopyArea (dpy, pix, win, gc, 0, 0, pixmapw, pixmaph, 10, 10); /* Draw the original tile next to it for reference */ XCopyArea (dpy, tile, win, gc, 0, 0, tilew, tileh, 10 + pixmapw + 10, 10); } } }