From http://www.jwz.org/xscreensaver/xscreensaver-5.35.tar.gz
[xscreensaver] / hacks / piecewise.c
index 09fc4b621609ae0e2e371759a8c4562500f6b59c..6e6e484f1db9fadf0af19d27cd2be1f8851bac21 100644 (file)
@@ -358,7 +358,7 @@ static circle *init_circles(struct state *st, int n, int w, int h)
   dr = floor(maxradius * h) - r0 + 1;
 
   for (i=0;i<n;i++) {
-    c[i].r = r0 + random() % dr;
+    c[i].r = r0 + ((dr > 0) ? random() % dr : 0);
     c[i].x = c[i].r + frand(w - 1 - 2 * c[i].r);
     c[i].y = c[i].r + frand(h - 1 - 2 * c[i].r);
     c[i].visible = random() & 1;
@@ -500,10 +500,12 @@ static void event_shred(event *e)
 
 /******** fringe intersection */
 
+#if 0
 static inline int check_fringe_intersection(double ye, fringe *lo, fringe *hi, double x, double y)
 {
   return ye <= y && ((x < lo->c->x) ^ lo->side) && ((x < hi->c->x) ^ hi->side);
   }
+#endif /* 0 */
 
 static void fringe_intersect(struct state *st, event **eq, double y, fringe *lo, fringe *hi)
 {
@@ -813,6 +815,7 @@ static void draw_circle(struct state *st, Drawable w, GC gc, circle *c)
 
 /******** toplevel */
 
+#if 0
 static void
 check_for_leaks (void)
 {
@@ -830,6 +833,7 @@ check_for_leaks (void)
     }
 #endif /* HAVE_SBRK */
 }
+#endif
 
 static void *
 piecewise_init (Display *dd, Window ww)
@@ -844,7 +848,7 @@ piecewise_init (Display *dd, Window ww)
   st->colorspeed = get_integer_resource(st->dpy, "colorspeed", "Integer");
   st->dbuf = get_boolean_resource(st->dpy, "doubleBuffer", "Boolean");
 
-# ifdef HAVE_COCOA     /* Don't second-guess Quartz's double-buffering */
+# ifdef HAVE_JWXYZ     /* Don't second-guess Quartz's double-buffering */
   st->dbuf = False;
 # endif
 
@@ -861,7 +865,9 @@ piecewise_init (Display *dd, Window ww)
       st->colors[0].pixel = get_pixel_resource(st->dpy, st->xgwa.colormap, "foreground", "Foreground");
     }
   else {
-    make_color_loop(st->dpy, st->xgwa.colormap, 0, 1, 1, 120, 1, 1, 240, 1, 1, st->colors, &st->ncolors, True, False);
+    make_color_loop(st->xgwa.screen, st->xgwa.visual, st->xgwa.colormap,
+                    0, 1, 1, 120, 1, 1, 240, 1, 1,
+                    st->colors, &st->ncolors, True, False);
     if (st->ncolors < 2)
       goto MONO; 
     }
@@ -932,7 +938,7 @@ piecewise_draw (Display *dpy, Window window, void *closure)
       st->b = (st->b == st->ba ? st->bb : st->ba);
     }
 
-  check_for_leaks();
+/*  check_for_leaks(); */
   return st->delay;
 }
 
@@ -940,6 +946,8 @@ static void
 piecewise_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);
 }
 
 static Bool
@@ -960,7 +968,7 @@ piecewise_free (Display *dpy, Window window, void *closure)
 static const char *piecewise_defaults [] = {
   ".background:         black",
   ".foreground:         white",
-  "*delay:              5000",
+  "*delay:              10000",
   "*speed:              15",
   "*ncolors:            256",
   ".colorspeed:         10",
@@ -973,6 +981,9 @@ static const char *piecewise_defaults [] = {
 #ifdef HAVE_DOUBLE_BUFFER_EXTENSION
   "*useDBE:             True",
 #endif /* HAVE_DOUBLE_BUFFER_EXTENSION */
+#ifdef HAVE_MOBILE
+  "*ignoreRotation:     True",
+#endif
   0
   };