X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fgalaxy.c;h=7f72af5b2ccb22b0aee64cb6c13af4805341d13f;hb=4361b69d3178d7fc98d0388f9a223af6c2651aba;hp=6a72738e508dda81b089ba216c6e082809ff7e97;hpb=c1b9b55ad8d59dc05ef55e316aebf5863e7dfa56;p=xscreensaver diff --git a/hacks/galaxy.c b/hacks/galaxy.c index 6a72738e..7f72af5b 100644 --- a/hacks/galaxy.c +++ b/hacks/galaxy.c @@ -45,10 +45,10 @@ static const char sccsid[] = "@(#)galaxy.c 4.04 97/07/28 xlockmore"; "*cycles: 250 \n" \ "*ncolors: 64 \n" \ "*fpsSolid: true \n" \ + "*ignoreRotation: True \n" \ # define UNIFORM_COLORS -# define reshape_galaxy 0 -# define galaxy_handle_event 0 +# define release_galaxy 0 # include "xlockmore.h" /* from the xscreensaver distribution */ #else /* !STANDALONE */ # include "xlock.h" /* from the xlockmore distribution */ @@ -159,8 +159,9 @@ x-axis */ static unistruct *universes = NULL; static void -free_galaxies(unistruct * gp) +free_galaxies(ModeInfo * mi) { + unistruct *gp = &universes[MI_SCREEN(mi)]; if (gp->galaxies != NULL) { int i; @@ -192,7 +193,7 @@ startover(ModeInfo * mi) gp->rot_x = 0; if (MI_BATCHCOUNT(mi) < -MINGALAXIES) - free_galaxies(gp); + free_galaxies(mi); gp->ngalaxies = MI_BATCHCOUNT(mi); if (gp->ngalaxies < -MINGALAXIES) gp->ngalaxies = NRAND(-gp->ngalaxies - MINGALAXIES + 1) + MINGALAXIES; @@ -307,14 +308,10 @@ init_galaxy(ModeInfo * mi) { unistruct *gp; - if (universes == NULL) { - if ((universes = (unistruct *) calloc(MI_NUM_SCREENS(mi), - sizeof (unistruct))) == NULL) - return; - } + MI_INIT (mi, universes, free_galaxies); gp = &universes[MI_SCREEN(mi)]; -# ifdef HAVE_COCOA /* Don't second-guess Quartz's double-buffering */ +# ifdef HAVE_JWXYZ /* Don't second-guess Quartz's double-buffering */ dbufp = False; # endif @@ -441,16 +438,10 @@ draw_galaxy(ModeInfo * mi) } ENTRYPOINT void -release_galaxy(ModeInfo * mi) +reshape_galaxy(ModeInfo * mi, int width, int height) { - if (universes != NULL) { - int screen; - - for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) - free_galaxies(&universes[screen]); - (void) free((void *) universes); - universes = NULL; - } + XClearWindow (MI_DISPLAY (mi), MI_WINDOW(mi)); + init_galaxy (mi); } ENTRYPOINT void @@ -459,4 +450,16 @@ refresh_galaxy(ModeInfo * mi) /* Do nothing, it will refresh by itself */ } +ENTRYPOINT Bool +galaxy_handle_event (ModeInfo *mi, XEvent *event) +{ + if (screenhack_event_helper (MI_DISPLAY(mi), MI_WINDOW(mi), event)) + { + reshape_galaxy (mi, MI_WIDTH(mi), MI_HEIGHT(mi)); + return True; + } + return False; +} + + XSCREENSAVER_MODULE ("Galaxy", galaxy)