From http://www.jwz.org/xscreensaver/xscreensaver-5.35.tar.gz
[xscreensaver] / hacks / shadebobs.c
index 39040ea377c66067619ea4bdc19932c23226d90a..7a1a0ffc13c258bad17567ba44150f7e6ee809d3 100644 (file)
@@ -52,6 +52,9 @@ static const char *shadebobs_defaults [] = {
   "*cycles:   10",
   "*ncolors:  64",    /* changing this doesn't work particularly well */
   "*delay:    10000",
+#ifdef HAVE_MOBILE
+  "*ignoreRotation: True",
+#endif
   0
 };
 
@@ -144,8 +147,11 @@ static void MoveShadeBob( struct state *st, SShadeBob *pShadeBob )
        pShadeBob->nAngle          += pShadeBob->nAngleInc;
        pShadeBob->nAngleDelta -= pShadeBob->nAngleInc;
 
-       if( pShadeBob->nAngle >= st->iDegreeCount )     pShadeBob->nAngle -= st->iDegreeCount;
-       else if( pShadeBob->nAngle < 0 )                pShadeBob->nAngle += st->iDegreeCount;
+       /* Since it can happen that nAngle < 0 and nAngle + iDegreeCount >= iDegreeCount
+          on floating point, we set some marginal value.
+       */
+       if( pShadeBob->nAngle + 0.5 >= st->iDegreeCount )       pShadeBob->nAngle -= st->iDegreeCount;
+       else if( pShadeBob->nAngle < -0.5 )             pShadeBob->nAngle += st->iDegreeCount;
        
        if( ( pShadeBob->nAngleInc>0.0F  && pShadeBob->nAngleDelta<pShadeBob->nAngleInc ) ||
            ( pShadeBob->nAngleInc<=0.0F && pShadeBob->nAngleDelta>pShadeBob->nAngleInc ) )
@@ -296,12 +302,13 @@ static void Initialize( struct state *st )
 {
        XGCValues gcValues;
        XWindowAttributes XWinAttribs;
-       int iBitsPerPixel;
+       /*int iBitsPerPixel;*/
 
        /* Create the Image for drawing */
        XGetWindowAttributes( st->dpy, st->window, &XWinAttribs );
 
-       /* Find the preferred bits-per-pixel. (jwz) */
+#if 0
+  /* Find the preferred bits-per-pixel. (jwz) */
        {
                int i, pfvc = 0;
                XPixmapFormatValues *pfv = XListPixmapFormats( st->dpy, &pfvc );
@@ -314,6 +321,7 @@ static void Initialize( struct state *st )
                if( pfv )
                        XFree (pfv);
        }
+#endif
 
        /*  Create the GC. */
        st->gc = XCreateGC( st->dpy, st->window, 0, &gcValues );