From http://www.jwz.org/xscreensaver/xscreensaver-5.38.tar.gz
[xscreensaver] / hacks / wormhole.c
index 631b42b86ad3f336c02e10f4639e950d4cff1ee1..f28c5b2514640688032bdefd7be59347ab772dcd 100644 (file)
@@ -1,5 +1,4 @@
-/* xscreensaver, Copyright (c) 1992, 1995, 1996, 1997, 1998, 2004, 2006
- *  Jamie Zawinski <jwz@jwz.org>
+/* xscreensaver, Copyright (c) 1992-2011 Jamie Zawinski <jwz@jwz.org>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -87,7 +86,7 @@ struct state {
 
 /*inline*/ static int rnd( int q )
 {
-
+       if (q < 1) q = 1;
        return random() % q;
 
 }
@@ -101,16 +100,16 @@ static int gang( int x1, int y1, int x2, int y2 )
                        tang = 90;
                else
                        tang = 270;
-       }
-       if ( y1 == y2 ) {
+       } else if ( y1 == y2 ) {
 
                if ( x1 < x2 )
                        tang = 0;
                else
                        tang = 180;
 
-       } else
-       tang = (int)(0.5+atan2( -(y2-y1), x2 - x1 ) * 180.0 / M_PI );
+       } else {
+          tang = (int)(0.5+atan2( -(y2-y1), x2 - x1 ) * 180.0 / M_PI );
+        }
 
        while ( tang < 0 )
                tang += 360;
@@ -170,7 +169,6 @@ static void initColorChanger( struct state *st, color_changer * ch )
 {
 
        int q;
-       int min, max;
        XColor old_color, new_color;
 
        ch->shade_max = 2048;
@@ -185,9 +183,6 @@ static void initColorChanger( struct state *st, color_changer * ch )
        initXColor( &new_color );
        
        for ( q = 0; q < ch->shade_max; q += ch->shade_use ){
-               min = q;
-               max = q + ch->shade_use;
-               if ( max >= ch->shade_max ) max = ch->shade_max-1;
                blend_palette( ch->shade + q, ch->shade_use, &old_color, &new_color );
                old_color = new_color;
 
@@ -308,7 +303,7 @@ static void resizeWormhole( struct state *st, wormhole * worm )
        st->SCREEN_X = attr.width;
        st->SCREEN_Y = attr.height;
 
-# ifndef HAVE_COCOA    /* Don't second-guess Quartz's double-buffering */
+# ifndef HAVE_JWXYZ    /* Don't second-guess Quartz's double-buffering */
        XFreePixmap( st->dpy, worm->work );
        worm->work = XCreatePixmap( st->dpy, st->window, st->SCREEN_X, st->SCREEN_Y, attr.depth );
 # endif
@@ -328,7 +323,7 @@ static void initWormhole( struct state *st, wormhole * worm, Display * display,
        st->SCREEN_X = attr.width;
        st->SCREEN_Y = attr.height;
 
-# ifdef HAVE_COCOA     /* Don't second-guess Quartz's double-buffering */
+# ifdef HAVE_JWXYZ     /* Don't second-guess Quartz's double-buffering */
         worm->work = st->window;
 # else
        worm->work = XCreatePixmap( st->dpy, st->window, st->SCREEN_X, st->SCREEN_Y, attr.depth );
@@ -708,11 +703,15 @@ wormhole_free (Display *dpy, Window window, void *closure)
 
 
 static const char *wormhole_defaults [] = {
+  ".lowrez:     true",
   ".background:        Black",
   ".foreground:        #E9967A",
   "*delay:     10000",
   "*zspeed:    10",
   "*stars:     20",
+#ifdef HAVE_MOBILE
+  "*ignoreRotation: True",
+#endif
   0
 };