X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fccurve.c;h=23b53e84da9f2bfdb92344fa646cba5239c8ea19;hb=aa75c7476aeaa84cf3abc192b376a8b03c325213;hp=02cb0ba329e87da2dd375f9c2f59b983384342b6;hpb=49f5b54f312fe4ac2e9bc47581a72451bd0e8439;p=xscreensaver diff --git a/hacks/ccurve.c b/hacks/ccurve.c index 02cb0ba3..23b53e84 100644 --- a/hacks/ccurve.c +++ b/hacks/ccurve.c @@ -178,7 +178,7 @@ realign (double x1, } } -static void +static Bool self_similar_normalized (struct state *st, int iterations, double x1, @@ -228,24 +228,36 @@ self_similar_normalized (struct state *st, assert (fabs ((replacement [segment_count - 1].x) - 1.0) < EPSILON); assert (fabs (replacement [segment_count - 1].y) < EPSILON); realign (x1, y1, x2, y2, segment_count, replacement); - assert (fabs (x2 - (replacement [segment_count - 1].x)) < EPSILON); - assert (fabs (y2 - (replacement [segment_count - 1].y)) < EPSILON); + /* jwz: I don't understand what these assertions are supposed to + be detecting, but let's just bail on the fractal instead of + crashing. */ +/* assert (fabs (x2 - (replacement [segment_count - 1].x)) < EPSILON); + assert (fabs (y2 - (replacement [segment_count - 1].y)) < EPSILON);*/ + if (fabs (x2 - (replacement [segment_count - 1].x)) >= EPSILON || + fabs (y2 - (replacement [segment_count - 1].y)) >= EPSILON) { + free (replacement); + return False; + } x = x1; y = y1; for (index = 0; index < segment_count; ++index) { next_x = replacement [index].x; next_y = replacement [index].y; - self_similar_normalized (st, + if (!self_similar_normalized (st, iterations - 1, x, y, next_x, next_y, maximum_x, maximum_y, minimum_x, minimum_y, - segment_count, points); + segment_count, points)) { + free(replacement); + return False; + } x = next_x; y = next_y; } - free((void*)replacement); + free(replacement); } + return True; } static void @@ -689,7 +701,8 @@ ccurve_init (Display *dpy, Window window) st->context = XCreateGC (st->dpy, st->window, GCForeground | GCBackground, &values); st->color_count = MAXIMUM_COLOR_COUNT; - make_color_loop (st->dpy, st->color_map, + make_color_loop (hack_attributes.screen, hack_attributes.visual, + st->color_map, 0, 1, 1, 120, 1, 1, 240, 1, 1, @@ -784,6 +797,7 @@ ccurve_draw (Display *dpy, Window window, void *closure) 0, 0); } st->draw_index++; + /* #### mi->recursion_depth = st->draw_index; */ if (st->draw_index >= st->draw_iterations) { @@ -800,11 +814,25 @@ static void ccurve_reshape (Display *dpy, Window window, void *closure, unsigned int w, unsigned int h) { + struct state *st = (struct state *) closure; + XWindowAttributes xgwa; + st->width = w; + st->height = h; + XGetWindowAttributes (st->dpy, st->window, &xgwa); + XFreePixmap (dpy, st->pixmap); + st->pixmap = XCreatePixmap (st->dpy, st->window, st->width, st->height, + xgwa.depth); } static Bool ccurve_event (Display *dpy, Window window, void *closure, XEvent *event) { + struct state *st = (struct state *) closure; + if (screenhack_event_helper (dpy, window, event)) + { + st->draw_index = 0; + return True; + } return False; } @@ -821,6 +849,9 @@ static const char *ccurve_defaults [] = ".delay: 3", ".pause: 0.4", ".limit: 200000", +#ifdef HAVE_MOBILE + "*ignoreRotation: True", +#endif 0 };