X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=hacks%2Finterference.c;h=78601439d9743fa1271803e2be963c8dba81bf6f;hp=cbb6fae9f09fec5388927d8b6f62563c63f43178;hb=refs%2Fheads%2Fmaster;hpb=78add6e627ee5f10e1fa6f3852602ea5066eee5a diff --git a/hacks/interference.c b/hacks/interference.c index cbb6fae9..63b8a83b 100644 --- a/hacks/interference.c +++ b/hacks/interference.c @@ -364,10 +364,8 @@ static void inter_free(Display* dpy, struct inter_context* c) destroy_image(dpy, c); - if(c->colors <= 2) - free(c->pal); - else if(c->pal) - free_colors(c->screen, c->cmap, c->pal, c->colors); + free_colors(c->screen, c->cmap, c->pal, c->colors); + if (c->pal) free(c->pal); #ifndef USE_XIMAGE for(i = 0; i != c->colors; ++i) @@ -696,6 +694,7 @@ static void inter_init(Display* dpy, Window win, struct inter_context* c) int mono; int gray; int radius; + double scale = 1; XGCValues val; Bool dbuf = get_boolean_resource (dpy, "doubleBuffer", "Boolean"); @@ -749,6 +748,10 @@ static void inter_init(Display* dpy, Window win, struct inter_context* c) if(radius < 1) radius = 1; + if (xgwa.width > 2560 || xgwa.height > 2560) + scale = 3.5; /* Retina displays */ + radius *= scale; + create_image(dpy, c, &xgwa); if(!mono) { @@ -843,15 +846,15 @@ static void inter_init(Display* dpy, Window win, struct inter_context* c) ((float)radius); c->wave_height[i] = (unsigned) - ((max + max*cos(fi/50.0)) / 2.0); + ((max + max*cos(fi/(50.0 * scale))) / 2.0); } c->source = calloc(c->count, sizeof(struct inter_source)); check_no_mem(dpy, c, c->source); for(i = 0; i < c->count; i++) { - c->source[i].x_theta = frand(2.0)*3.14159; - c->source[i].y_theta = frand(2.0)*3.14159; + c->source[i].x_theta = frand(2.0)*M_PI; + c->source[i].y_theta = frand(2.0)*M_PI; } c->last_frame = float_time(); @@ -888,11 +891,11 @@ static unsigned long do_inter(struct inter_context* c) for(i = 0; i < c->count; i++) { c->source[i].x_theta += (elapsed*c->speed/1000.0); - if(c->source[i].x_theta > 2.0*3.14159) - c->source[i].x_theta -= 2.0*3.14159; + if(c->source[i].x_theta > 2.0*M_PI) + c->source[i].x_theta -= 2.0*M_PI; c->source[i].y_theta += (elapsed*c->speed/1000.0); - if(c->source[i].y_theta > 2.0*3.14159) - c->source[i].y_theta -= 2.0*3.14159; + if(c->source[i].y_theta > 2.0*M_PI) + c->source[i].y_theta -= 2.0*M_PI; c->source[i].x = source_x(c, i); c->source[i].y = source_y(c, i); } @@ -991,6 +994,7 @@ interference_free (Display *dpy, Window window, void *closure) { struct inter_context *c = (struct inter_context *) closure; inter_free(dpy, c); + free(c); } XSCREENSAVER_MODULE ("Interference", interference)