X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fepicycle.c;h=89fab0b26f073c645adef703aeb55cad75e9b553;hb=39809ded547bdbb08207d3e514950425215b4410;hp=4eae8c945d288618c45446b92b63d402e1c293ed;hpb=c1b9b55ad8d59dc05ef55e316aebf5863e7dfa56;p=xscreensaver diff --git a/hacks/epicycle.c b/hacks/epicycle.c index 4eae8c94..89fab0b2 100644 --- a/hacks/epicycle.c +++ b/hacks/epicycle.c @@ -65,6 +65,9 @@ static const char *epicycle_defaults [] = { "*divisorPoisson: 0.4", "*sizeFactorMin: 1.05", "*sizeFactorMax: 2.05", +#ifdef HAVE_MOBILE + "*ignoreRotation: True", +#endif 0 }; @@ -225,14 +228,6 @@ random_divisor(struct state *st) } -static void -oom(struct state *st) -{ - fprintf(stderr, "Failed to allocate memory!\n"); - exit(-1); -} - - /* Construct a circle or die. */ static Circle * @@ -311,8 +306,7 @@ static Body * new_body(struct state *st) { Body *p = malloc(sizeof(Body)); - if (NULL == p) - oom(st); + if (!p) abort(); p->epicycles = new_circle_chain(st); p->current_color = 0; /* ?? start them all on different colors? */ p->next = NULL; @@ -410,7 +404,7 @@ colour_init(struct state *st, XWindowAttributes *pxgwa) */ if (st->colors) { - free_colors(st->dpy, st->cmap, st->colors, st->ncolors); + free_colors(pxgwa->screen, st->cmap, st->colors, st->ncolors); st->colors = 0; st->ncolors = 0; } @@ -428,10 +422,10 @@ colour_init(struct state *st, XWindowAttributes *pxgwa) if (!mono_p) { st->colors = (XColor *) malloc(sizeof(*st->colors) * (st->ncolors+1)); - if (!st->colors) - oom(st); + if (!st->colors) abort(); - make_smooth_colormap (st->dpy, pxgwa->visual, st->cmap, st->colors, &st->ncolors, + make_smooth_colormap (pxgwa->screen, pxgwa->visual, st->cmap, + st->colors, &st->ncolors, True, /* allocate */ False, /* not writable */ True); /* verbose (complain about failure) */ @@ -624,6 +618,17 @@ static void rescale_circles(struct state *st, Body *pb, { printf("enlarge by x%.2f skipped...\n", scale); } + + if (st->width > st->height * 5 || /* window has weird aspect */ + st->height > st->width * 5) + { + Circle *p; + double r = (st->width > st->height + ? st->width / (double) st->height + : st->height / (double) st->width); + for (p=pb->epicycles; p; p=p->pchild) + p->radius *= r; + } } @@ -729,7 +734,7 @@ epicycle_draw (Display *dpy, Window window, void *closure) st->L = compute_divisor_lcm(st->pb0->epicycles); - st->colour_cycle_rate = fabs(st->L); + st->colour_cycle_rate = labs(st->L); st->xtime = fabs(st->L * st->circle / st->wdot_max); @@ -770,7 +775,7 @@ static Bool epicycle_event (Display *dpy, Window window, void *closure, XEvent *e) { struct state *st = (struct state *) closure; - if (e->type == ButtonPress) + if (screenhack_event_helper (dpy, window, e)) { st->restart = 1; return True;