X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Floop.c;h=ad3e1b02cd211467c8c56c18afbdf245c1593743;hb=4ade52359b6eba3621566dac79793a33aa4c915f;hp=e271951960fa97cf4fe97cc93d276e181f35e287;hpb=ffd8c0873576a9e3065696a624dce6b766b77062;p=xscreensaver diff --git a/hacks/loop.c b/hacks/loop.c index e2719519..ad3e1b02 100644 --- a/hacks/loop.c +++ b/hacks/loop.c @@ -79,22 +79,25 @@ static const char sccsid[] = "@(#)loop.c 5.01 2000/03/15 xlockmore"; there is handedness at both the initial condition and the transition rule. */ +#ifndef HAVE_COCOA +# define DO_STIPPLE +#endif + #ifdef STANDALONE -#define MODE_loop -#define PROGCLASS "loop" -#define HACK_INIT init_loop -#define HACK_DRAW draw_loop -#define loop_opts xlockmore_opts -#define DEFAULTS "*delay: 100000 \n" \ - "*count: -5 \n" \ - "*cycles: 1600 \n" \ - "*size: -12 \n" \ - "*ncolors: 15 \n" \ - "*neighbors: 0 \n" -#define UNIFORM_COLORS -#include "xlockmore.h" /* in xscreensaver distribution */ +# define MODE_loop +# define DEFAULTS "*delay: 100000 \n" \ + "*count: -5 \n" \ + "*cycles: 1600 \n" \ + "*size: -12 \n" \ + "*ncolors: 15 \n" \ + "*fpsSolid: true \n" \ + "*ignoreRotation: True \n" \ + +# define UNIFORM_COLORS +# define loop_handle_event 0 +# include "xlockmore.h" /* in xscreensaver distribution */ #else /* STANDALONE */ -#include "xlock.h" /* in xlockmore distribution */ +# include "xlock.h" /* in xlockmore distribution */ #endif /* STANDALONE */ #include "automata.h" @@ -122,7 +125,7 @@ static OptionStruct desc[] = {"-neighbors num", "squares 4 or hexagons 6"} }; -ModeSpecOpt loop_opts = +ENTRYPOINT ModeSpecOpt loop_opts = {sizeof opts / sizeof opts[0], opts, sizeof vars / sizeof vars[0], vars, desc}; @@ -858,11 +861,16 @@ drawcell(ModeInfo * mi, int col, int row, int state) gc = MI_GC(mi); XSetForeground(MI_DISPLAY(mi), gc, lp->colors[state]); } else { +#ifdef DO_STIPPLE gcv.stipple = lp->pixmaps[state]; +#endif /* DO_STIPPLE */ gcv.foreground = MI_WHITE_PIXEL(mi); gcv.background = MI_BLACK_PIXEL(mi); XChangeGC(MI_DISPLAY(mi), lp->stippledGC, - GCStipple | GCForeground | GCBackground, &gcv); +#ifdef DO_STIPPLE + GCStipple | +#endif /* DO_STIPPLE */ + GCForeground | GCBackground, &gcv); gc = lp->stippledGC; } fillcell(mi, gc, col, row); @@ -966,11 +974,16 @@ draw_state(ModeInfo * mi, int state) gc = MI_GC(mi); XSetForeground(display, gc, lp->colors[state]); } else { +#ifdef DO_STIPPLE gcv.stipple = lp->pixmaps[state]; +#endif /* DO_STIPPLE */ gcv.foreground = MI_WHITE_PIXEL(mi); gcv.background = MI_BLACK_PIXEL(mi); XChangeGC(display, lp->stippledGC, - GCStipple | GCForeground | GCBackground, &gcv); +#ifdef DO_STIPPLE + GCStipple | +#endif /* DO_STIPPLE */ + GCForeground | GCBackground, &gcv); gc = lp->stippledGC; } @@ -1016,7 +1029,6 @@ draw_state(ModeInfo * mi, int state) (void) free((void *) rects); } free_state(lp, state); - XFlush(display); return True; } @@ -1140,7 +1152,7 @@ static void init_adam(ModeInfo * mi) { loopstruct *lp = &loops[MI_SCREEN(mi)]; - XPoint start, dirx, diry; + XPoint start = { 0, 0 }, dirx = { 0, 0 }, diry = { 0, 0 }; int i, j, dir; #ifdef DELAYDEBUGLOOP @@ -1408,8 +1420,8 @@ do_gen(loopstruct * lp) } } -void -release_loop(ModeInfo * mi) +ENTRYPOINT void +release_loop (ModeInfo * mi) { if (loops != NULL) { int screen; @@ -1428,14 +1440,12 @@ release_loop(ModeInfo * mi) static void *stop_warning_about_triangleUnit_already; -void -init_loop(ModeInfo * mi) +ENTRYPOINT void +init_loop (ModeInfo * mi) { Display *display = MI_DISPLAY(mi); - Window window = MI_WINDOW(mi); int i, size = MI_SIZE(mi); loopstruct *lp; - XGCValues gcv; stop_warning_about_triangleUnit_already = (void *) &triangleUnit; @@ -1448,8 +1458,11 @@ init_loop(ModeInfo * mi) lp->redrawing = 0; +#ifdef DO_STIPPLE if ((MI_NPIXELS(mi) < COLORS) && (lp->init_bits == 0)) { - if (lp->stippledGC == None) { + Window window = MI_WINDOW(mi); + XGCValues gcv; + if (lp->stippledGC == None) { gcv.fill_style = FillOpaqueStippled; if ((lp->stippledGC = XCreateGC(display, window, GCFillStyle, &gcv)) == None) { @@ -1466,6 +1479,7 @@ init_loop(ModeInfo * mi) LOOPBITS(stipples[8], STIPPLESIZE, STIPPLESIZE); LOOPBITS(stipples[10], STIPPLESIZE, STIPPLESIZE); } +#endif /* DO_STIPPLE */ if (MI_NPIXELS(mi) >= COLORS) { /* Maybe these colors should be randomized */ lp->colors[0] = MI_BLACK_PIXEL(mi); @@ -1596,8 +1610,8 @@ init_loop(ModeInfo * mi) init_adam(mi); } -void -draw_loop(ModeInfo * mi) +ENTRYPOINT void +draw_loop (ModeInfo * mi) { int offset, i, j; unsigned char *z, *znew; @@ -1664,8 +1678,15 @@ draw_loop(ModeInfo * mi) } } -void -refresh_loop(ModeInfo * mi) +ENTRYPOINT void +reshape_loop(ModeInfo * mi, int width, int height) +{ + XClearWindow (MI_DISPLAY (mi), MI_WINDOW(mi)); + init_loop (mi); +} + +ENTRYPOINT void +refresh_loop (ModeInfo * mi) { loopstruct *lp; @@ -1678,4 +1699,6 @@ refresh_loop(ModeInfo * mi) lp->redrawpos = lp->by * lp->ncols + lp->bx; } +XSCREENSAVER_MODULE ("Loop", loop) + #endif /* MODE_loop */