static void distort_free (Display *dpy, Window window, void *closure) { struct state *st = (struct state *) closure; XFreeGC (st->dpy, st->gc); if (st->pm) XFreePixmap (dpy, st->pm); if (st->orig_map) XDestroyImage (st->orig_map); if (st->buffer_map) destroy_xshm_image (st->dpy, st->buffer_map, &st->shm_info); if (st->from) free (st->from); if (st->fast_from) free (st->fast_from); if (st->from_array) free (st->from_array); free (st); }
static void twang_free (Display *dpy, Window window, void *closure) { struct state *st = (struct state *) closure; if (st->pm) XFreePixmap (dpy, st->pm); XFreeGC (dpy, st->backgroundGC); XFreeGC (dpy, st->foregroundGC); XFreeGC (dpy, st->borderGC); if (st->sourceImage) XDestroyImage (st->sourceImage); if (st->workImage) destroy_xshm_image (st->dpy, st->workImage, &st->shmInfo); if (st->tiles) free (st->tiles); if (st->sortedTiles) free (st->sortedTiles); free (st); }
static void grabImage_done (struct state *st) { XWindowAttributes xwa; XGetWindowAttributes (st->dpy, st->window, &xwa); st->start_time = time ((time_t *) 0); if (st->sourceImage) XDestroyImage (st->sourceImage); st->sourceImage = XGetImage (st->dpy, st->pm, 0, 0, st->windowWidth, st->windowHeight, ~0L, ZPixmap); if (st->workImage) destroy_xshm_image (st->dpy, st->workImage, &st->shmInfo); st->workImage = create_xshm_image (st->dpy, xwa.visual, xwa.depth, ZPixmap, &st->shmInfo, st->windowWidth, st->windowHeight); }
static unsigned long moire_draw (Display *dpy, Window window, void *closure) { struct state *st = (struct state *) closure; XGCValues gcv; int chunk_size = 20, ii; if (st->draw_y == 0) { moire_init_1 (st); XGetWindowAttributes (st->dpy, st->window, &st->xgwa); st->draw_xo = (random() % st->xgwa.width) - st->xgwa.width/2; st->draw_yo = (random() % st->xgwa.height) - st->xgwa.height/2; st->draw_factor = (random() % st->offset) + 1; st->depth = visual_depth(DefaultScreenOfDisplay(st->dpy), st->xgwa.visual); # ifdef HAVE_XSHM_EXTENSION if (st->use_shm) { st->draw_image = create_xshm_image(st->dpy, st->xgwa.visual, st->depth, ZPixmap, 0, &st->shm_info, st->xgwa.width, 1); if (!st->draw_image) st->use_shm = False; } # endif /* HAVE_XSHM_EXTENSION */ if (!st->draw_image) { st->draw_image = XCreateImage (st->dpy, st->xgwa.visual, st->depth, ZPixmap, 0, /* depth, format, offset */ 0, st->xgwa.width, 1, 8, 0); /* data, w, h, pad, bpl */ st->draw_image->data = (char *) calloc(st->draw_image->height, st->draw_image->bytes_per_line); } } /* for (y = 0; y < st->xgwa.height; y++) */ for (ii = 0; ii < chunk_size; ii++) { int x; for (x = 0; x < st->xgwa.width; x++) { double xx = x + st->draw_xo; double yy = st->draw_y + st->draw_yo; double i = ((xx * xx) + (yy * yy)) / (double) st->draw_factor; if (mono_p) gcv.foreground = ((((long) i) & 1) ? st->fg_pixel : st->bg_pixel); else gcv.foreground = st->colors[((long) i) % st->ncolors].pixel; XPutPixel (st->draw_image, x, 0, gcv.foreground); } # ifdef HAVE_XSHM_EXTENSION if (st->use_shm) XShmPutImage(st->dpy, st->window, st->gc, st->draw_image, 0, 0, 0, st->draw_y, st->xgwa.width, 1, False); else # endif /* HAVE_XSHM_EXTENSION */ XPutImage (st->dpy, st->window, st->gc, st->draw_image, 0, 0, 0, st->draw_y, st->xgwa.width, 1); st->draw_y++; if (st->draw_y >= st->xgwa.height) break; } if (st->draw_y >= st->xgwa.height) { st->draw_y = 0; # ifdef HAVE_XSHM_EXTENSION if (!st->use_shm) # endif /* HAVE_XSHM_EXTENSION */ if (st->draw_image->data) { free(st->draw_image->data); st->draw_image->data = 0; } # ifdef HAVE_XSHM_EXTENSION if (st->use_shm) destroy_xshm_image (st->dpy, st->draw_image, &st->shm_info); else # endif /* HAVE_XSHM_EXTENSION */ XDestroyImage (st->draw_image); st->draw_image = 0; return st->delay * 1000000; } return st->delay * 10000; }