From http://www.jwz.org/xscreensaver/xscreensaver-5.38.tar.gz
[xscreensaver] / hacks / mountain.c
index aae435b5886c4ade4eaa3d4be34e2856a2958e05..541b18735beb798da4da25c08594b219e2521f27 100644 (file)
@@ -28,11 +28,14 @@ static const char sccsid[] = "@(#)mountain.c        5.00 2000/11/01 xlockmore";
 
 #ifdef STANDALONE
 # define MODE_mountain
-#define DEFAULTS       "*delay: 1000 \n" \
+#define DEFAULTS       "*delay: 20000 \n" \
                                        "*count: 30 \n" \
                                        "*cycles: 4000 \n" \
-                                       "*ncolors: 64 \n"
+                                       "*ncolors: 64 \n" \
+                                       "*fpsSolid: true \n" \
+
 # define SMOOTH_COLORS
+# define release_mountain 0
 # define reshape_mountain 0
 # define mountain_handle_event 0
 # include "xlockmore.h"                /* in xscreensaver distribution */
@@ -47,8 +50,8 @@ ENTRYPOINT ModeSpecOpt mountain_opts =
 
 #ifdef USE_MODULES
 ModStruct   mountain_description =
-{"mountain", "init_mountain", "draw_mountain", "release_mountain",
- "refresh_mountain", "init_mountain", (char *) NULL, &mountain_opts,
+{"mountain", "init_mountain", "draw_mountain", (char *) NULL,
+ "refresh_mountain", "init_mountain", "free_mountain", &mountain_opts,
  1000, 30, 4000, 1, 64, 1.0, "",
  "Shows Papo's mountain range", 0, NULL};
 
@@ -168,11 +171,7 @@ init_mountain (ModeInfo * mi)
        XGCValues   gcv;
        mountainstruct *mp;
 
-       if (mountains == NULL) {
-               if ((mountains = (mountainstruct *) calloc(MI_NUM_SCREENS(mi),
-                                          sizeof (mountainstruct))) == NULL)
-                       return;
-       }
+       MI_INIT (mi, mountains);
        mp = &mountains[MI_SCREEN(mi)];
 
        mp->width = MI_WIDTH(mi);
@@ -254,22 +253,15 @@ draw_mountain (ModeInfo * mi)
 }
 
 ENTRYPOINT void
-release_mountain (ModeInfo * mi)
+free_mountain (ModeInfo * mi)
 {
-       if (mountains != NULL) {
-               int         screen;
-
-               for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) {
-                       mountainstruct *mp = &mountains[screen];
+       mountainstruct *mp = &mountains[MI_SCREEN(mi)];
 
-                       if (mp->stippledGC)
-                               XFreeGC(MI_DISPLAY(mi), mp->stippledGC);
-               }
-               (void) free((void *) mountains);
-               mountains = (mountainstruct *) NULL;
-       }
+       if (mp->stippledGC)
+               XFreeGC(MI_DISPLAY(mi), mp->stippledGC);
 }
 
+#ifndef STANDALONE
 ENTRYPOINT void
 refresh_mountain(ModeInfo * mi)
 {
@@ -283,6 +275,7 @@ refresh_mountain(ModeInfo * mi)
        mp->x = 0;
        mp->y = 0;
 }
+#endif
 
 XSCREENSAVER_MODULE ("Mountain", mountain)