X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fforest.c;h=38a480d9351fcbf76b7ea34baeff94bcedafa90b;hb=39809ded547bdbb08207d3e514950425215b4410;hp=07d96e6abc197023d9172ead4de45b5e605af767;hpb=49f5b54f312fe4ac2e9bc47581a72451bd0e8439;p=xscreensaver diff --git a/hacks/forest.c b/hacks/forest.c index 07d96e6a..38a480d9 100644 --- a/hacks/forest.c +++ b/hacks/forest.c @@ -28,9 +28,12 @@ #ifdef STANDALONE # define DEFAULTS "*delay: 500000 \n" \ - "*ncolors: 20 \n" + "*ncolors: 20 \n" \ + "*fpsSolid: true \n" \ + # include "xlockmore.h" /* from the xscreensaver distribution */ -# define refresh_trees 0 +# define free_trees 0 +# define release_trees 0 # define reshape_trees 0 # define trees_handle_event 0 #else /* !STANDALONE */ @@ -66,17 +69,12 @@ static long colorV[12] = {0x0a0000, 0x0a0500, 0x0a0a00, 0x050a00, ENTRYPOINT void init_trees(ModeInfo * mi) { - unsigned long pixels[20]; treestruct *tree; Display *display = MI_DISPLAY(mi); GC gc = MI_GC(mi); int i; if (trees == NULL) { - trees = (treestruct *) calloc(MI_NUM_SCREENS(mi), sizeof (treestruct)); - if (trees == NULL) { - return; - } if (mi->npixels > 20) { printf("%d colors selected. Setting limit to 20...\n", mi->npixels); @@ -115,6 +113,8 @@ init_trees(ModeInfo * mi) XSetForeground(display, gc, colors[1].pixel); } + MI_INIT (mi, trees); + XClearWindow(display, MI_WINDOW(mi)); XSetLineAttributes(display, gc, 2, LineSolid, CapButt, JoinMiter); tree = &trees[MI_SCREEN(mi)]; @@ -130,12 +130,7 @@ init_trees(ModeInfo * mi) colors[i].flags = DoRed | DoGreen | DoBlue; } - for (i = 0; i < color; i++) - pixels[i] = colors[i].pixel; - - XFreeColors(display, mi->xgwa.colormap, pixels, mi->npixels, 0L); - - for (i = 0; i < mi->npixels; i++) + for (i = 0; i < mi->npixels; i++) if (!XAllocColor(display, mi->xgwa.colormap, &colors[i])) break; color = i; @@ -246,13 +241,4 @@ draw_trees(ModeInfo * mi) } -ENTRYPOINT void -release_trees(ModeInfo * mi) -{ - if (trees != NULL) { - (void) free((void *) trees); - trees = NULL; - } -} - XSCREENSAVER_MODULE_2 ("Forest", forest, trees)