/* test_nosync_copyarea.c Last Update: Sun Oct 27 19:13:04 MET 2002 by Stefan Kral License: GPL Version 2 (or higher) */ #include #include #include #define FALSE 0 int main(int argc, char **argv) { if (argc < 4) { printf("usage: test_copyarea \n"); return 127; } else { Display *dpy; int width = atoi(argv[1]), height = atoi(argv[2]), iter = atoi(argv[3]); if ((dpy = XOpenDisplay(NULL)) == NULL) { fprintf(stderr, "cannot open display\n"); return 1; } else { Window root = DefaultRootWindow(dpy); int screen = DefaultScreen(dpy); GC gc1, gc2; XGCValues values; int j; unsigned long black = BlackPixel(dpy, screen); unsigned long white = WhitePixel(dpy, screen); Window w = XCreateSimpleWindow(dpy, root, 10, 10, width, height, 0, black, white); Drawable buf = XCreatePixmap(dpy, w, width, height, DefaultDepth(dpy, screen)); values.foreground = BlackPixel(dpy, screen); values.background = WhitePixel(dpy, screen); gc1 = XCreateGC(dpy, buf, (GCForeground | GCBackground), &values); values.foreground = WhitePixel(dpy, screen); values.background = BlackPixel(dpy, screen); gc2 = XCreateGC(dpy, buf, (GCForeground | GCBackground), &values); XSetGraphicsExposures(dpy, gc1, FALSE); XSetGraphicsExposures(dpy, gc2, FALSE); XMapRaised(dpy, w); for (j = 0; j < iter; j++) { XFillRectangle(dpy, buf, gc2, 0, 0, width, height); XCopyArea(dpy, buf, w, gc2, 0, 0, width, height, 0, 0); XFillRectangle(dpy, buf, gc1, 0, 0, width, height); XCopyArea(dpy, buf, w, gc2, 0, 0, width, height, 0, 0); } XFreePixmap(dpy,buf); XDestroyWindow(dpy, w); // also unmaps the window XCloseDisplay(dpy); return 0; } } }