X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fmountain.c;h=dcabbe54db3d9a412af2c9f20ddf2d1deed8e51e;hb=4361b69d3178d7fc98d0388f9a223af6c2651aba;hp=82d5fce7e82482c219083302113fe95badcf3cf0;hpb=6f5482d73adb0165c0130bb47d852644ab0c4869;p=xscreensaver diff --git a/hacks/mountain.c b/hacks/mountain.c index 82d5fce7..dcabbe54 100644 --- a/hacks/mountain.c +++ b/hacks/mountain.c @@ -35,7 +35,7 @@ static const char sccsid[] = "@(#)mountain.c 5.00 2000/11/01 xlockmore"; "*fpsSolid: true \n" \ # define SMOOTH_COLORS -# define mountain_handle_event 0 +# define release_mountain 0 # include "xlockmore.h" /* in xscreensaver distribution */ #else /* STANDALONE */ # include "xlock.h" /* in xlockmore distribution */ @@ -48,7 +48,7 @@ ENTRYPOINT ModeSpecOpt mountain_opts = #ifdef USE_MODULES ModStruct mountain_description = -{"mountain", "init_mountain", "draw_mountain", "release_mountain", +{"mountain", "init_mountain", "draw_mountain", (char *) NULL, "refresh_mountain", "init_mountain", (char *) NULL, &mountain_opts, 1000, 30, 4000, 1, 64, 1.0, "", "Shows Papo's mountain range", 0, NULL}; @@ -162,6 +162,8 @@ drawamountain(ModeInfo * mi) mp->stage++; } +static void free_mountain (ModeInfo * mi); + ENTRYPOINT void init_mountain (ModeInfo * mi) { @@ -169,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, free_mountain); mp = &mountains[MI_SCREEN(mi)]; mp->width = MI_WIDTH(mi); @@ -262,21 +260,13 @@ reshape_mountain(ModeInfo * mi, int width, int height) } -ENTRYPOINT void -release_mountain (ModeInfo * mi) +static void +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); } ENTRYPOINT void @@ -293,6 +283,17 @@ refresh_mountain(ModeInfo * mi) mp->y = 0; } +ENTRYPOINT Bool +mountain_handle_event (ModeInfo *mi, XEvent *event) +{ + if (screenhack_event_helper (MI_DISPLAY(mi), MI_WINDOW(mi), event)) + { + init_mountain (mi); + return True; + } + return False; +} + XSCREENSAVER_MODULE ("Mountain", mountain) #endif /* MODE_mountain */