#undef DO_VORONOI
-#ifndef HAVE_COCOA
+#ifndef HAVE_JWXYZ
# define XK_MISCELLANY
# include <X11/keysymdef.h>
#endif
tessellimage_init (Display *dpy, Window window)
{
struct state *st = (struct state *) calloc (1, sizeof(*st));
- Colormap cmap;
st->dpy = dpy;
st->window = window;
XGetWindowAttributes (st->dpy, st->window, &st->xgwa);
- cmap = st->xgwa.colormap;
st->delay = get_integer_resource (st->dpy, "delay", "Integer");
if (st->delay < 1) st->delay = 1;
static unsigned long
-pixel_distance (Visual *v, unsigned long p1, unsigned long p2)
+pixel_distance (Screen *s, Visual *v, unsigned long p1, unsigned long p2)
{
static int initted_p = 0;
- static unsigned int rmsk=0, gmsk=0, bmsk=0;
+ static unsigned long rmsk=0, gmsk=0, bmsk=0;
static unsigned int rpos=0, gpos=0, bpos=0;
static unsigned int rsiz=0, gsiz=0, bsiz=0;
if (!p1 && !p2) return 0;
if (! initted_p) {
- rmsk = v->red_mask;
- gmsk = v->green_mask;
- bmsk = v->blue_mask;
+ visual_rgb_masks (s, v, &rmsk, &gmsk, &bmsk);
decode_mask (rmsk, &rpos, &rsiz);
decode_mask (gmsk, &gpos, &gsiz);
decode_mask (bmsk, &bpos, &bsiz);
pixels[i++] = (x > 0 && y < h-1 ? XGetPixel (st->img, x-1, y+1) : 0);
for (i = 1; i < countof(pixels); i++)
- distance += pixel_distance (st->xgwa.visual, pixels[0], pixels[i]);
+ distance += pixel_distance (st->xgwa.screen, st->xgwa.visual,
+ pixels[0], pixels[i]);
distance /= countof(pixels)-1;
XPutPixel (st->delta, x, y, distance);
}
st->pgc = XCreateGC(st->dpy, st->image, GCFunction, &gcv);
}
+ if (! st->nthreshes) return;
+
+
/* If duration2 has expired, switch to the next threshold. */
if (! st->button_down_p)
if (ticked_p && st->cache[st->thresh])
{
- XCopyArea (st->dpy,
- st->cache[st->thresh],
- st->output, st->pgc,
- 0, 0, st->delta->width, st->delta->height,
- 0, 0);
+ if (st->output)
+ XCopyArea (st->dpy,
+ st->cache[st->thresh],
+ st->output, st->pgc,
+ 0, 0, st->delta->width, st->delta->height,
+ 0, 0);
}
else if (ticked_p)
{
fprintf (stderr, "%s: out of memory\n", progname);
abort();
}
- XCopyArea (st->dpy,
- st->output,
- st->cache[st->thresh],
- st->pgc,
- 0, 0, st->delta->width, st->delta->height,
- 0, 0);
+ if (st->output)
+ XCopyArea (st->dpy,
+ st->output,
+ st->cache[st->thresh],
+ st->pgc,
+ 0, 0, st->delta->width, st->delta->height,
+ 0, 0);
}
}
XImage *dimg;
Visual *v = st->xgwa.visual;
- unsigned int rmsk=0, gmsk=0, bmsk=0;
+ unsigned long rmsk=0, gmsk=0, bmsk=0;
unsigned int rpos=0, gpos=0, bpos=0;
unsigned int rsiz=0, gsiz=0, bsiz=0;
if (st->deltap) return st->deltap;
- rmsk = v->red_mask;
- gmsk = v->green_mask;
- bmsk = v->blue_mask;
+ visual_rgb_masks (st->xgwa.screen, v, &rmsk, &gmsk, &bmsk);
decode_mask (rmsk, &rpos, &rsiz);
decode_mask (gmsk, &gpos, &gsiz);
decode_mask (bmsk, &bpos, &bsiz);
0, 0, st->delta->width, st->delta->height,
(st->xgwa.width - st->delta->width) / 2,
(st->xgwa.height - st->delta->height) / 2);
+ else if (!st->nthreshes)
+ XCopyArea (st->dpy,
+ st->image,
+ st->window, st->wgc,
+ 0, 0, st->xgwa.width, st->xgwa.height,
+ 0,
+ 0);
+
DONE:
return st->delay;
st->button_down_p = False;
return True;
}
- else if (event->xany.type == KeyPress)
+ else if (screenhack_event_helper (dpy, window, event))
{
- KeySym keysym = 0;
- char c = 0;
- if (event->xany.type == KeyPress || event->xany.type == KeyRelease)
- XLookupString (&event->xkey, &c, 1, &keysym, 0);
-
- switch (keysym) {
- case XK_Left:
- case XK_Right:
- case XK_Down:
- case XK_Up:
- st->start_time = 0; /* load next image */
- return True;
- }
-
- switch (c) {
- case '\r':
- case '\n':
- case '+':
- case '=':
- st->start_time = 0;
- return True;
- }
+ st->start_time = 0; /* load next image */
+ return True;
}
return False;
{
struct state *st = (struct state *) closure;
flush_cache (st);
- XFreeGC (dpy, st->wgc);
- XFreeGC (dpy, st->pgc);
+ if (st->wgc) XFreeGC (dpy, st->wgc);
+ if (st->pgc) XFreeGC (dpy, st->pgc);
if (st->image) XFreePixmap (dpy, st->image);
if (st->output) XFreePixmap (dpy, st->output);
if (st->delta) XDestroyImage (st->delta);
"*outline: True",
"*fillScreen: True",
"*cache: True",
-#ifdef USE_IPHONE
+#ifdef HAVE_MOBILE
"*ignoreRotation: True",
+ "*rotateImages: True",
#endif
0
};