X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fdistort.c;h=8173c43b96bcdc61a1ff92217abc3b2cc52e5003;hb=4ade52359b6eba3621566dac79793a33aa4c915f;hp=7755f0283fda8c722c23ef29b1c2e28a06a4dd0c;hpb=49f5b54f312fe4ac2e9bc47581a72451bd0e8439;p=xscreensaver diff --git a/hacks/distort.c b/hacks/distort.c index 7755f028..8173c43b 100644 --- a/hacks/distort.c +++ b/hacks/distort.c @@ -1,5 +1,5 @@ /* -*- mode: C; tab-width: 4 -*- - * xscreensaver, Copyright (c) 1992-2006 Jamie Zawinski + * xscreensaver, Copyright (c) 1992-2013 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -61,6 +61,9 @@ struct state { struct coo xy_coo[10]; int delay, radius, speed, number, blackhole, vortex, magnify, reflect, slow; + int duration; + time_t start_time; + XWindowAttributes xgwa; GC gc; unsigned long black_pixel; @@ -115,10 +118,14 @@ distort_init (Display *dpy, Window window) st->window = window; st->delay = get_integer_resource(st->dpy, "delay", "Integer"); + st->duration = get_integer_resource (st->dpy, "duration", "Seconds"); st->radius = get_integer_resource(st->dpy, "radius", "Integer"); st->speed = get_integer_resource(st->dpy, "speed", "Integer"); st->number = get_integer_resource(st->dpy, "number", "Integer"); + if (st->delay < 0) st->delay = 0; + if (st->duration < 1) st->duration = 1; + #ifdef HAVE_XSHM_EXTENSION st->use_shm = get_boolean_resource(st->dpy, "useSHM", "Boolean"); #endif /* HAVE_XSHM_EXTENSION */ @@ -277,6 +284,7 @@ distort_init (Display *dpy, Window window) st->img_loader = load_image_async_simple (0, st->xgwa.screen, st->window, st->window, 0, 0); + st->start_time = time ((time_t) 0); return st; } @@ -285,6 +293,8 @@ distort_finish_loading (struct state *st) { int i; + st->start_time = time ((time_t) 0); + st->buffer_map = 0; st->orig_map = XGetImage(st->dpy, st->window, 0, 0, st->xgwa.width, st->xgwa.height, ~0L, ZPixmap); @@ -747,11 +757,19 @@ distort_draw (Display *dpy, Window window, void *closure) if (st->img_loader) /* still loading */ { st->img_loader = load_image_async_simple (st->img_loader, 0, 0, 0, 0, 0); - if (! st->img_loader) /* just finished */ + if (! st->img_loader) { /* just finished */ distort_finish_loading (st); + } return st->delay; } + if (!st->img_loader && + st->start_time + st->duration < time ((time_t) 0)) { + st->img_loader = load_image_async_simple (0, st->xgwa.screen, st->window, + st->window, 0, 0); + return st->delay; + } + for (k = 0; k < st->number; k++) { st->effect(st,k); st->draw(st,k); @@ -763,6 +781,13 @@ static void distort_reshape (Display *dpy, Window window, void *closure, unsigned int w, unsigned int h) { + struct state *st = (struct state *) closure; + XGetWindowAttributes (st->dpy, st->window, &st->xgwa); + /* XClearWindow (dpy, window); */ + /* Why doesn't this work? */ + if (st->orig_map) /* created in distort_finish_loading, might be early */ + XPutImage (st->dpy, st->window, st->gc, st->orig_map, + 0, 0, st->orig_map->width, st->orig_map->height, 0, 0); } static Bool @@ -790,11 +815,13 @@ distort_free (Display *dpy, Window window, void *closure) static const char *distort_defaults [] = { "*dontClearRoot: True", "*background: Black", + "*fpsSolid: true", #ifdef __sgi /* really, HAVE_READ_DISPLAY_EXTENSION */ "*visualID: Best", #endif "*delay: 20000", + "*duration: 120", "*radius: 0", "*speed: 0", "*number: 0", @@ -807,11 +834,15 @@ static const char *distort_defaults [] = { #ifdef HAVE_XSHM_EXTENSION "*useSHM: False", /* xshm turns out not to help. */ #endif /* HAVE_XSHM_EXTENSION */ +#ifdef USE_IPHONE + "*ignoreRotation: True", +#endif 0 }; static XrmOptionDescRec distort_options [] = { { "-delay", ".delay", XrmoptionSepArg, 0 }, + { "-duration", ".duration", XrmoptionSepArg, 0 }, { "-radius", ".radius", XrmoptionSepArg, 0 }, { "-speed", ".speed", XrmoptionSepArg, 0 }, { "-number", ".number", XrmoptionSepArg, 0 },