From http://www.jwz.org/xscreensaver/xscreensaver-5.30.tar.gz
[xscreensaver] / hacks / eruption.c
index 14809b9f7d80095788707c93001ed5b08b8da5eb..629cb8e1e5d2654e4b38a821212543f452bf7878 100644 (file)
@@ -298,7 +298,7 @@ static void Initialize( struct state *st )
 {
        XGCValues gcValues;
        XWindowAttributes XWinAttribs;
-       int iBitsPerPixel, i;
+       int /*iBitsPerPixel,*/ i;
 
        /* Create the Image for drawing */
        XGetWindowAttributes( st->dpy, st->window, &XWinAttribs );
@@ -310,7 +310,7 @@ static void Initialize( struct state *st )
                for( i=0; i<pfvc; i++ )
                        if( pfv[ i ].depth == XWinAttribs.depth )
                        {
-                               iBitsPerPixel = pfv[ i ].bits_per_pixel;
+                               /*iBitsPerPixel = pfv[ i ].bits_per_pixel;*/
                                break;
                        }
                if( pfv )
@@ -346,7 +346,6 @@ eruption_init (Display *dpy, Window window)
        time_t nTime = time( NULL );
        unsigned short iFrame = 0;
 #endif  /*  VERBOSE */
-        int i;
 
   st->dpy = dpy;
   st->window = window;
@@ -397,7 +396,6 @@ eruption_init (Display *dpy, Window window)
 
        st->delay = get_integer_resource(st->dpy,  "delay", "Integer" );
        st->cycles = get_integer_resource(st->dpy,  "cycles", "Integer" );
-       i = st->cycles;
 
        cache(st);
        
@@ -451,6 +449,28 @@ static void
 eruption_reshape (Display *dpy, Window window, void *closure, 
                  unsigned int w, unsigned int h)
 {
+  struct state *st = (struct state *) closure;
+  XWindowAttributes XWinAttribs;
+  int i;
+
+  for (i = 0; i < st->iWinHeight; ++i)
+    free (st->fire[i]);
+
+  st->iWinWidth = w;
+  st->iWinHeight = h;
+
+  free (st->fire);
+  st->fire = calloc( st->iWinHeight, sizeof(unsigned char*));
+  for (i = 0; i < st->iWinHeight; ++i)
+    st->fire[i] = calloc( st->iWinWidth, sizeof(unsigned char));
+
+  XDestroyImage( st->pImage );
+  XGetWindowAttributes( st->dpy, st->window, &XWinAttribs );
+  st->pImage = XCreateImage( st->dpy, XWinAttribs.visual, XWinAttribs.depth, ZPixmap, 0, NULL,
+                                                         XWinAttribs.width, XWinAttribs.height, BitmapPad( st->dpy ), 0 );
+  (st->pImage)->data = calloc((st->pImage)->bytes_per_line, (st->pImage)->height);
+
+  st->draw_i = -1;
 }
 
 static Bool
@@ -464,7 +484,6 @@ eruption_free (Display *dpy, Window window, void *closure)
 {
 #if 0
   struct state *st = (struct state *) closure;
-       free( st->pImage->data );
        XDestroyImage( st->pImage );
        free( st->aiColorVals );
        for (i = 0; i < st->iWinHeight; ++i)
@@ -478,6 +497,7 @@ eruption_free (Display *dpy, Window window, void *closure)
 static const char *eruption_defaults [] = {
   ".background: black",
   ".foreground: white",
+  "*fpsTop:    true",
   "*cycles:   80",
   "*ncolors:  256",
   "*delay:    10000",