From http://www.jwz.org/xscreensaver/xscreensaver-5.37.tar.gz
[xscreensaver] / hacks / interaggregate.c
index 441bd8465ca67d336f7e96d9632bf6204a74c1e0..6308841f8fb2bfcc503a1f3b8fa5dfe61c5444fc 100644 (file)
@@ -73,6 +73,7 @@ static const char *interaggregate_defaults[] =
 {
     ".background: white",
     ".foreground: black",
+    "*fpsSolid:        true",
     "*maxCycles: 100000",
 #ifdef TIME_ME
     "*growthDelay: 0",
@@ -84,6 +85,9 @@ static const char *interaggregate_defaults[] =
     "*baseOrbits: 75",
     "*baseOnCenter: False",
     "*drawCenters: False",
+#ifdef HAVE_MOBILE
+    "*ignoreRotation: True",
+#endif
     0
 };
 
@@ -255,7 +259,7 @@ static inline void point2rgb(int depth, unsigned long c, int *r, int *g, int *b)
     {
     case 32:
     case 24:
-#ifdef HAVE_COCOA
+#ifdef HAVE_JWXYZ
         /* This program idiotically does not go through a color map, so
            we have to hardcode in knowledge of how jwxyz.a packs pixels!
            Fix it to go through st->colors[st->ncolors] instead!
@@ -270,14 +274,14 @@ static inline void point2rgb(int depth, unsigned long c, int *r, int *g, int *b)
 #endif
        break;
     case 16:
-       *b = (c & 0x1f) << 3; 
-       *g = ((c >> 5) & 0x3f) << 2;
-       *r = ((c >> 11) & 0x1f) << 3; 
+       *b = (int) (c & 0x1f) << 3;
+       *g = (int) ((c >> 5) & 0x3f) << 2;
+       *r = (int) ((c >> 11) & 0x1f) << 3;
        break;
     case 15:
-       *b = (c & 0x1f) << 3;
-       *g = ((c >> 5) & 0x1f) << 3;
-       *r = ((c >> 10) & 0x1f) << 3;
+       *b = (int) (c & 0x1f) << 3;
+       *g = (int) ((c >> 5) & 0x1f) << 3;
+       *r = (int) ((c >> 10) & 0x1f) << 3;
        break;
     }
 }
@@ -289,9 +293,8 @@ static inline unsigned long rgb2point(int depth, int r, int g, int b)
     switch(depth) 
     {
     case 32:
-       ret = 0xff000000;
     case 24:
-#ifdef HAVE_COCOA
+#ifdef HAVE_JWXYZ
         /* This program idiotically does not go through a color map, so
            we have to hardcode in knowledge of how jwxyz.a packs pixels!
            Fix it to go through st->colors[st->ncolors] instead!
@@ -352,11 +355,11 @@ static inline void drawPoint(int x, int y, unsigned long color, double intensity
 {
     unsigned long c;
 
-    if ( x >= f->width ) x -= f->width;
-    else if ( x < 0 ) x += f->width;
+    while ( x >= f->width ) x -= f->width;
+    while ( x < 0 ) x += f->width;
        
-    if ( y >= f->height ) y -= f->height;
-    else if ( y < 0 ) y += f->height;
+    while ( y >= f->height ) y -= f->height;
+    while ( y < 0 ) y += f->height;
 
     /* if ( in_bounds(f, x, y) ) ... */
 
@@ -437,6 +440,7 @@ static void build_colors(struct field *f, Display *dpy, XWindowAttributes *xgwa)
        ;
     }
 
+    if (f->numcolors < 1) f->numcolors = 1;
     f->parsedcolors = (unsigned long *) calloc(f->numcolors,
                                               sizeof(unsigned long));
     if ( f->parsedcolors == NULL )
@@ -566,7 +570,7 @@ static void build_field(Display *dpy, Window window, XWindowAttributes xgwa, GC
        {
            if (i < base_orbits )
            {
-               if ( f->base_on_center )
+               if ( f->base_on_center )
                    circle->center = &f->center_of_universe; 
                else
                {
@@ -719,7 +723,9 @@ static void drawIntersections(Display *dpy, Window window, GC fgc, struct field
                double d, dsqr, dx, dy;
                Circle *c2 = f->circles + j;
 
+#ifdef TIME_ME
                ++f->possible_intersections;
+#endif
                dx = c2->x - c1->x;
                dy = c2->y - c1->y;
 
@@ -745,7 +751,9 @@ static void drawIntersections(Display *dpy, Window window, GC fgc, struct field
                     * intersection 
                     */
 
+#ifdef TIME_ME
                    ++f->intersection_count;
+#endif
 
                    /* unit vector in direction of c1 to c2 */
                    bx = dx / d;
@@ -953,6 +961,12 @@ interaggregate_reshape (Display *dpy, Window window, void *closure,
 static Bool
 interaggregate_event (Display *dpy, Window window, void *closure, XEvent *event)
 {
+  struct state *st = (struct state *) closure;
+  if (screenhack_event_helper (dpy, window, event))
+    {
+      st->f->height--;  /* act like a resize */
+      return True;
+    }
   return False;
 }