- XGetWindowAttributes (dpy, window, &xgwa);
- cmap = xgwa.colormap;
- how_many = get_integer_resource ("count", "Integer");
- frequency = get_integer_resource ("frequency", "Integer");
- scatter = get_integer_resource ("scatter", "Integer");
- if (how_many <= 0) how_many = 100;
- if (frequency <= 0) frequency = 30;
- if (scatter <= 0) scatter = 20;
- projectiles = 0;
- free_projectiles = 0;
- projectiles = (struct projectile *)
- calloc (how_many, sizeof (*projectiles));
- sorted_projectiles = (struct projectile **)
- calloc (how_many, sizeof (*sorted_projectiles));
- for (i = 0; i < how_many; i++)
- free_projectile (&projectiles [i]);
- for (i = 0; i < how_many; i++)
- sorted_projectiles[i] = &projectiles[i];
- gcv.foreground = default_fg_pixel =
- get_pixel_resource ("foreground", "Foreground", dpy, cmap);
- draw_gc = XCreateGC (dpy, window, GCForeground, &gcv);
- gcv.foreground = get_pixel_resource ("background", "Background", dpy, cmap);
- erase_gc = XCreateGC (dpy, window, GCForeground, &gcv);
- XClearWindow (dpy, window);
- cache();
- return cmap;
+ st->dpy = dpy;
+ st->window = window;
+ XGetWindowAttributes (st->dpy, st->window, &xgwa);
+ st->last_pixel = ~0;
+ st->cmap = xgwa.colormap;
+ st->delay = get_integer_resource (st->dpy, "delay", "Integer");
+ st->how_many = get_integer_resource (st->dpy, "count", "Integer");
+ st->frequency = get_integer_resource (st->dpy, "frequency", "Integer");
+ st->scatter = get_integer_resource (st->dpy, "scatter", "Integer");
+ if (st->how_many <= 0) st->how_many = 100;
+ if (st->frequency <= 0) st->frequency = 30;
+ if (st->scatter <= 0) st->scatter = 20;
+ st->projectiles = 0;
+ st->free_projectiles = 0;
+ st->projectiles = (struct projectile *)
+ calloc (st->how_many, sizeof (*st->projectiles));
+ st->sorted_projectiles = (struct projectile **)
+ calloc (st->how_many, sizeof (*st->sorted_projectiles));
+ for (i = 0; i < st->how_many; i++)
+ free_projectile (st, &st->projectiles [i]);
+ for (i = 0; i < st->how_many; i++)
+ st->sorted_projectiles[i] = &st->projectiles[i];
+ gcv.foreground = st->default_fg_pixel =
+ get_pixel_resource (st->dpy, st->cmap, "foreground", "Foreground");
+ st->draw_gc = XCreateGC (st->dpy, st->window, GCForeground, &gcv);
+ gcv.foreground = get_pixel_resource (st->dpy, st->cmap, "background", "Background");
+ st->erase_gc = XCreateGC (st->dpy, st->window, GCForeground, &gcv);
+ XClearWindow (st->dpy, st->window);
+ cache(st);
+
+ return st;