X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fgreynetic.c;h=4a17ba36f114d7f6bd1b0bafc7a8929511f84cce;hb=c28aecf9fc41e3a03494bacf7279745425e2fa18;hp=4dd3f172b608578507d2bff2d0dd72f5b67e5f0c;hpb=ccbc9f87eb59497b23bd0424ee1ed20ad7c7db54;p=xscreensaver diff --git a/hacks/greynetic.c b/hacks/greynetic.c index 4dd3f172..4a17ba36 100644 --- a/hacks/greynetic.c +++ b/hacks/greynetic.c @@ -1,4 +1,5 @@ -/* xscreensaver, Copyright (c) 1992, 1995 Jamie Zawinski +/* xscreensaver, Copyright (c) 1992, 1995, 1996, 1997, 1998 + * Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -13,18 +14,75 @@ #define NBITS 12 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +/* On some systems (notably MacOS X) these files are messed up. + * They're tiny, so we might as well just inline them here. + * + * # include + * # include + * # include + * # include + * # include + * # include + * # include + * # include + * # include + * # include + * # include + * # include +*/ + +#define stipple_width 16 +#define stipple_height 4 +static char stipple_bits[] = { 0x55, 0x55, 0xee, 0xee, 0x55, 0x55, 0xba, 0xbb}; + +#define cross_weave_width 16 +#define cross_weave_height 16 +static char cross_weave_bits[] = { + 0x55, 0x55, 0x88, 0x88, 0x55, 0x55, 0x22, 0x22, 0x55, 0x55, 0x88, 0x88, + 0x55, 0x55, 0x22, 0x22, 0x55, 0x55, 0x88, 0x88, 0x55, 0x55, 0x22, 0x22, + 0x55, 0x55, 0x88, 0x88, 0x55, 0x55, 0x22, 0x22}; + +#define dimple1_width 16 +#define dimple1_height 16 +static char dimple1_bits[] = { + 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, + 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, + 0x55, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00}; + +#define dimple3_width 16 +#define dimple3_height 16 +static char dimple3_bits[] = { + 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +#define flipped_gray_width 4 +#define flipped_gray_height 2 +static char flipped_gray_bits[] = { 0x07, 0x0d}; +#define gray1_width 2 +#define gray1_height 2 +static char gray1_bits[] = { 0x01, 0x02}; +#define gray3_width 4 +#define gray3_height 4 +static char gray3_bits[] = { 0x01, 0x00, 0x04, 0x00}; +#define hlines2_width 1 +#define hlines2_height 2 +static char hlines2_bits[] = { 0x01, 0x00}; +#define light_gray_width 4 +#define light_gray_height 2 +static char light_gray_bits[] = { 0x08, 0x02}; +#define root_weave_width 4 +#define root_weave_height 4 +static char root_weave_bits[] = { 0x07, 0x0d, 0x0b, 0x0e}; +#define vlines2_width 2 +#define vlines2_height 1 +static char vlines2_bits[] = { 0x01}; +#define vlines3_width 3 +#define vlines3_height 1 +static char vlines3_bits[] = { 0x02}; + + + static Pixmap pixmaps [NBITS]; static GC gc; @@ -33,9 +91,7 @@ static unsigned long fg, bg, pixels [512]; static int npixels; static void -init_greynetic (dpy, window) - Display *dpy; - Window window; +init_greynetic (Display *dpy, Window window) { int i; XGCValues gcv; @@ -71,13 +127,11 @@ init_greynetic (dpy, window) } static void -greynetic (dpy, window) - Display *dpy; - Window window; +greynetic (Display *dpy, Window window) { static int tick = 500, xlim, ylim; static Colormap cmap; - int x, y, w, h, i; + int x, y, w=0, h=0, i; XGCValues gcv; if (tick++ == 500) { @@ -100,6 +154,7 @@ greynetic (dpy, window) gcv.stipple = pixmaps [random () % NBITS]; if (mono_p) { + MONO: if (random () & 1) gcv.foreground = fg, gcv.background = bg; else @@ -127,6 +182,11 @@ greynetic (dpy, window) gcv.background = bgc.pixel; goto DONE; REUSE: + if (npixels <= 0) + { + mono_p = 1; + goto MONO; + } gcv.foreground = pixels [random () % npixels]; gcv.background = pixels [random () % npixels]; DONE: @@ -134,33 +194,32 @@ greynetic (dpy, window) } XChangeGC (dpy, gc, GCStipple|GCForeground|GCBackground, &gcv); XFillRectangle (dpy, window, gc, x, y, w, h); - XSync (dpy, True); + XSync (dpy, False); } char *progclass = "Greynetic"; char *defaults [] = { - "Greynetic.background: black", /* to placate SGI */ - "Greynetic.foreground: white", - "*delay: 0", + ".background: black", + ".foreground: white", + "*delay: 10000", 0 }; XrmOptionDescRec options [] = { - { "-delay", ".delay", XrmoptionSepArg, 0 } + { "-delay", ".delay", XrmoptionSepArg, 0 }, + { 0, 0, 0, 0 } }; -int options_size = (sizeof (options) / sizeof (options[0])); void -screenhack (dpy, window) - Display *dpy; - Window window; +screenhack (Display *dpy, Window window) { init_greynetic (dpy, window); while (1) { greynetic (dpy, window); + screenhack_handle_events (dpy); if (delay) usleep (delay); } }