From http://www.jwz.org/xscreensaver/xscreensaver-5.38.tar.gz
[xscreensaver] / hacks / epicycle.c
index 288999fa95bbf7220b50769c69d3d950a3600db3..89fab0b26f073c645adef703aeb55cad75e9b553 100644 (file)
@@ -65,7 +65,7 @@ static const char *epicycle_defaults [] = {
   "*divisorPoisson: 0.4",
   "*sizeFactorMin: 1.05",
   "*sizeFactorMax: 2.05",
-#ifdef USE_IPHONE
+#ifdef HAVE_MOBILE
   "*ignoreRotation: True",
 #endif
   0
@@ -618,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;
+    }
 }
 
 
@@ -723,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);
 
@@ -764,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;