X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fpopsquares.c;h=065ad06d4e9189642e06dffb75826d20a57ccf1b;hb=aa75c7476aeaa84cf3abc192b376a8b03c325213;hp=0bea52ef6c9145aff1b4043d9bf2538d6b76b983;hpb=07faf451b99879183ed7e909e43a0e065be1ee7f;p=xscreensaver diff --git a/hacks/popsquares.c b/hacks/popsquares.c index 0bea52ef..065ad06d 100644 --- a/hacks/popsquares.c +++ b/hacks/popsquares.c @@ -69,7 +69,7 @@ popsquares_init (Display *dpy, Window window) st->twitch = get_boolean_resource(st->dpy, "twitch", "Boolean"); st->dbuf = get_boolean_resource(st->dpy, "doubleBuffer", "Boolean"); -# ifdef HAVE_COCOA /* Don't second-guess Quartz's double-buffering */ +# ifdef HAVE_JWXYZ /* Don't second-guess Quartz's double-buffering */ st->dbuf = False; # endif @@ -86,6 +86,8 @@ popsquares_init (Display *dpy, Window window) st->gw = st->sw ? st->xgwa.width / st->sw : 0; st->gh = st->sh ? st->xgwa.height / st->sh : 0; st->nsquares = st->gw * st->gh; + if (st->nsquares < 1) st->nsquares = 1; + if (st->ncolors < 1) st->ncolors = 1; gcv.foreground = fg.pixel; gcv.background = bg.pixel; @@ -96,7 +98,7 @@ popsquares_init (Display *dpy, Window window) rgb_to_hsv (fg.red, fg.green, fg.blue, &h1, &s1, &v1); rgb_to_hsv (bg.red, bg.green, bg.blue, &h2, &s2, &v2); - make_color_ramp (st->dpy, st->xgwa.colormap, + make_color_ramp (st->xgwa.screen, st->xgwa.visual, st->xgwa.colormap, h1, s1, v1, h2, s2, v2, st->colors, &st->ncolors, /* would this be considered a value-result argument? */ @@ -187,6 +189,37 @@ static void popsquares_reshape (Display *dpy, Window window, void *closure, unsigned int w, unsigned int h) { + struct state *st = (struct state *) closure; + int x, y; + XGetWindowAttributes (st->dpy, st->window, &st->xgwa); + st->sw = st->xgwa.width / st->subdivision; + st->sh = st->xgwa.height / st->subdivision; + st->gw = st->sw ? st->xgwa.width / st->sw : 0; + st->gh = st->sh ? st->xgwa.height / st->sh : 0; + st->nsquares = st->gw * st->gh; + free (st->squares); + if (st->nsquares < 1) st->nsquares = 1; + st->squares = (square *) calloc (st->nsquares, sizeof(square)); + + for (y = 0; y < st->gh; y++) + for (x = 0; x < st->gw; x++) + { + square *s = (square *) &st->squares[st->gw * y + x]; + s->w = st->sw; + s->h = st->sh; + s->x = x * st->sw; + s->y = y * st->sh; + } + + randomize_square_colors(st->squares, st->nsquares, st->ncolors); + + if (st->dbuf) { + XFreePixmap (dpy, st->ba); + XFreePixmap (dpy, st->bb); + st->ba = XCreatePixmap (st->dpy, st->window, st->xgwa.width, st->xgwa.height, st->xgwa.depth); + st->bb = XCreatePixmap (st->dpy, st->window, st->xgwa.width, st->xgwa.height, st->xgwa.depth); + st->b = st->ba; + } } static Bool @@ -216,6 +249,9 @@ static const char *popsquares_defaults [] = { "*useDBE: True", "*useDBEClear: True", #endif /* HAVE_DOUBLE_BUFFER_EXTENSION */ +#ifdef HAVE_MOBILE + "*ignoreRotation: True", +#endif 0 };