X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fpyro.c;h=b62e17ac71c6fb4d2d72b58aa658ae23737b2788;hb=0bd2eabab3e404c6769fe8f59b639275e960c415;hp=996f7833d72dc7723662283aef7ec8c542350aaa;hpb=ccbc9f87eb59497b23bd0424ee1ed20ad7c7db54;p=xscreensaver diff --git a/hacks/pyro.c b/hacks/pyro.c index 996f7833..b62e17ac 100644 --- a/hacks/pyro.c +++ b/hacks/pyro.c @@ -1,4 +1,5 @@ -/* xscreensaver, Copyright (c) 1992, 1994 Jamie Zawinski +/* xscreensaver, Copyright (c) 1992, 1994, 1996 + * 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 @@ -30,7 +31,7 @@ struct projectile { static struct projectile *projectiles, *free_projectiles; static struct projectile * -get_projectile () +get_projectile (void) { struct projectile *p; if (free_projectiles) @@ -46,8 +47,7 @@ get_projectile () } static void -free_projectile (p) - struct projectile *p; +free_projectile (struct projectile *p) { p->next_free = free_projectiles; free_projectiles = p; @@ -55,10 +55,8 @@ free_projectile (p) } static void -launch (xlim, ylim, g, dpy, cmap) - int xlim, ylim, g; - Display *dpy; - Colormap cmap; +launch (int xlim, int ylim, int g, + Display *dpy, Colormap cmap) { struct projectile *p = get_projectile (); int x, dx, xxx; @@ -87,16 +85,13 @@ launch (xlim, ylim, g, dpy, cmap) if (!XAllocColor (dpy, cmap, &p->color)) { p->color.pixel = WhitePixel (dpy, DefaultScreen (dpy)); - p->color.red = p->color.green = p->color.blue = 0; + p->color.red = p->color.green = p->color.blue = 0xFFFF; } } } static struct projectile * -shrapnel (parent, dpy, cmap) - struct projectile *parent; - Display *dpy; - Colormap cmap; +shrapnel (struct projectile *parent, Display *dpy, Colormap cmap) { struct projectile *p = get_projectile (); if (! p) return 0; @@ -122,9 +117,7 @@ static unsigned int default_fg_pixel; static int how_many, frequency, scatter; static Colormap -init_pyro (dpy, window) - Display *dpy; - Window window; +init_pyro (Display *dpy, Window window) { int i; Colormap cmap; @@ -154,10 +147,7 @@ init_pyro (dpy, window) } static void -pyro (dpy, window, cmap) - Display *dpy; - Window window; - Colormap cmap; +pyro (Display *dpy, Window window, Colormap cmap) { XWindowAttributes xgwa; static int xlim, ylim, real_xlim, real_ylim; @@ -215,13 +205,15 @@ pyro (dpy, window, cmap) else { free_projectile (p); - if (! mono_p) XFreeColors (dpy, cmap, &p->color.pixel, 1, 0); + if (! mono_p) + if (p->color.pixel != WhitePixel (dpy, DefaultScreen (dpy))) + XFreeColors (dpy, cmap, &p->color.pixel, 1, 0); } if (p->primary && p->fuse <= 0) { - int i = (random () % scatter) + (scatter/2); - while (i--) + int j = (random () % scatter) + (scatter/2); + while (j--) shrapnel (p, dpy, cmap); } } @@ -231,8 +223,8 @@ pyro (dpy, window, cmap) char *progclass = "Pyro"; char *defaults [] = { - "Pyro.background: black", /* to placate SGI */ - "Pyro.foreground: white", + ".background: black", + ".foreground: white", "*count: 100", "*frequency: 30", "*scatter: 20", @@ -243,14 +235,12 @@ char *defaults [] = { XrmOptionDescRec options [] = { { "-count", ".count", XrmoptionSepArg, 0 }, { "-frequency", ".frequency", XrmoptionSepArg, 0 }, - { "-scatter", ".scatter", XrmoptionSepArg, 0 } + { "-scatter", ".scatter", 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) { Colormap cmap = init_pyro (dpy, window); while (1)