X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Ffireworkx.c;h=db1c8d8168a658096cea796f3b7b18603f59de57;hb=d1ae2829ff0fd2a96c16a0c8c5420efaa47d7b30;hp=18148a3e3dc052237483255e65bd621a6689c543;hpb=ff35d056d723c9a5ffe728dbba5f1c25e141be04;p=xscreensaver diff --git a/hacks/fireworkx.c b/hacks/fireworkx.c index 18148a3e..db1c8d81 100644 --- a/hacks/fireworkx.c +++ b/hacks/fireworkx.c @@ -45,7 +45,7 @@ #define HEIGHT 632 /* 548 */ #define SHELLCOUNT 4 /* FIXED NUMBER; for SSE optimization */ #define PIXCOUNT 500 /* 500 */ -#define SHELL_LIFE_DEFAULT 3200 /* 3200 */ +#define SHELL_LIFE_DEFAULT 32 /* 32 */ #define SHELL_LIFE_RATIO 6 /* 6 */ #define POWDER 5.0 /* 5.0 */ #define FTWEAK 12 /* 12 */ @@ -100,6 +100,9 @@ struct state int depth; int bigendian; int ncolors; + Bool button_down_p; + int deferred; + }; /* @@ -709,6 +712,9 @@ fireworkx_init (Display *dpy, Window win) st->shoot = get_boolean_resource(st->dpy, "shoot" , "Boolean"); st->verbose = get_boolean_resource(st->dpy, "verbose" , "Boolean"); st->max_shell_life = get_integer_resource(st->dpy, "maxlife" , "Integer"); + /* transition from xscreensaver <= 5.20 */ + if (st->max_shell_life > 100) st->max_shell_life = 100; + st->delay = get_integer_resource(st->dpy, "delay" , "Integer"); st->max_shell_life = pow(10.0,(st->max_shell_life/50.0)+2.7); @@ -735,7 +741,8 @@ fireworkx_init (Display *dpy, Window win) { st->colors = (XColor *) calloc(sizeof(XColor),st->ncolors+1); writable = False; - make_smooth_colormap(st->dpy, vi, cmap, st->colors, &st->ncolors, + make_smooth_colormap(xwa.screen, vi, cmap, + st->colors, &st->ncolors, False, &writable, True); } st->gc = XCreateGC(st->dpy, win, 0, &gcv); @@ -773,11 +780,19 @@ fireworkx_draw (Display *dpy, Window win, void *closure) { if (!explode(st, fs)) { - recycle(st, fs, rnd(st->width), rnd(st->height)); + if (st->button_down_p) + st->deferred++; + else + recycle(st, fs, rnd(st->width), rnd(st->height)); } } } + while (!st->button_down_p && st->deferred) { + st->deferred--; + recycle_oldest(st, rnd(st->width), rnd(st->height)); + } + glow_blur(st); if (st->flash_on) @@ -806,8 +821,15 @@ fireworkx_event (Display *dpy, Window window, void *closure, XEvent *event) if (event->type == ButtonPress) { recycle_oldest(st, event->xbutton.x, event->xbutton.y); + st->button_down_p = True; return True; } + else if (event->type == ButtonRelease) + { + st->button_down_p = False; + return True; + } + return False; }