From http://www.jwz.org/xscreensaver/xscreensaver-5.38.tar.gz
[xscreensaver] / hacks / spiral.c
index 214cbfbbaa524d1b80ff6c5c786b70b9cbb128e9..3d8159beaf46e90c223710ffd92e826a6a729e86 100644 (file)
@@ -1,9 +1,8 @@
 /* -*- Mode: C; tab-width: 4 -*- */
 /* spiral --- spiraling dots */
 
-#if !defined( lint ) && !defined( SABER )
+#if 0
 static const char sccsid[] = "@(#)spiral.c     5.00 2000/11/01 xlockmore";
-
 #endif
 
 /*-
@@ -35,30 +34,31 @@ static const char sccsid[] = "@(#)spiral.c  5.00 2000/11/01 xlockmore";
  */
 
 #ifdef STANDALONE
-#define MODE_spiral
-#define PROGCLASS "Spiral"
-#define HACK_INIT init_spiral
-#define HACK_DRAW draw_spiral
-#define spiral_opts xlockmore_opts
-#define DEFAULTS "*delay: 50000 \n" \
- "*count: 40 \n" \
- "*cycles: 350 \n" \
- "*ncolors: 64 \n"
-#define SMOOTH_COLORS
-#include "xlockmore.h"         /* from the xscreensaver distribution */
+# define MODE_spiral
+#define DEFAULTS       "*delay: 50000 \n" \
+                                       "*count: 40 \n" \
+                                       "*cycles: 350 \n" \
+                                       "*ncolors: 64 \n" \
+                                       "*fpsSolid: true \n" \
+
+# define SMOOTH_COLORS
+# define release_spiral 0
+# define reshape_spiral 0
+# define spiral_handle_event 0
+# include "xlockmore.h"                /* from the xscreensaver distribution */
 #else /* !STANDALONE */
-#include "xlock.h"             /* from the xlockmore distribution */
+# include "xlock.h"            /* from the xlockmore distribution */
 #endif /* !STANDALONE */
 
 #ifdef MODE_spiral
 
-ModeSpecOpt spiral_opts =
+ENTRYPOINT ModeSpecOpt spiral_opts =
 {0, (XrmOptionDescRec *) NULL, 0, (argtype *) NULL, (OptionStruct *) NULL};
 
 #ifdef USE_MODULES
 ModStruct   spiral_description =
-{"spiral", "init_spiral", "draw_spiral", "release_spiral",
- "refresh_spiral", "init_spiral", (char *) NULL, &spiral_opts,
+{"spiral", "init_spiral", "draw_spiral", (char *) NULL,
+ "refresh_spiral", "init_spiral", "free_spiral", &spiral_opts,
  5000, -40, 350, 1, 64, 1.0, "",
  "Shows a helical locus of points", 0, NULL};
 
@@ -122,19 +122,19 @@ draw_dots(ModeInfo * mi, int in)
        }
 }
 
-void
+ENTRYPOINT void
 init_spiral(ModeInfo * mi)
 {
        spiralstruct *sp;
        int         i;
 
-       if (spirals == NULL) {
-               if ((spirals = (spiralstruct *) calloc(MI_NUM_SCREENS(mi),
-                                            sizeof (spiralstruct))) == NULL)
-                       return;
-       }
+       MI_INIT (mi, spirals);
        sp = &spirals[MI_SCREEN(mi)];
 
+#ifdef HAVE_JWXYZ
+    jwxyz_XSetAntiAliasing (MI_DISPLAY(mi), MI_GC(mi),  False);
+#endif
+
        sp->width = MI_WIDTH(mi);
        sp->height = MI_HEIGHT(mi);
 
@@ -191,7 +191,7 @@ init_spiral(ModeInfo * mi)
                sp->dots = MINDOTS;
 }
 
-void
+ENTRYPOINT void
 draw_spiral(ModeInfo * mi)
 {
        Display    *display = MI_DISPLAY(mi);
@@ -296,24 +296,21 @@ draw_spiral(ModeInfo * mi)
        }
 }
 
-void
-release_spiral(ModeInfo * mi)
+ENTRYPOINT void
+free_spiral(ModeInfo * mi)
 {
-       if (spirals != NULL) {
-               int         screen;
+       spiralstruct *sp;
 
-               for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) {
-                       spiralstruct *sp = &spirals[screen];
+       if (spirals == NULL)
+               return;
+       sp = &spirals[MI_SCREEN(mi)];
 
-                       if (sp->traildots)
-                               (void) free((void *) sp->traildots);
-               }
-               (void) free((void *) spirals);
-               spirals = (spiralstruct *) NULL;
-       }
+       if (sp->traildots)
+               (void) free((void *) sp->traildots);
 }
 
-void
+#ifndef STANDALONE
+ENTRYPOINT void
 refresh_spiral(ModeInfo * mi)
 {
        spiralstruct *sp;
@@ -326,5 +323,8 @@ refresh_spiral(ModeInfo * mi)
        sp->redrawing = 1;
        sp->redrawpos = 0;
 }
+#endif
+
+XSCREENSAVER_MODULE ("Spiral", spiral)
 
 #endif /* MODE_spiral */