X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fhalo.c;h=fc69ea730af60d27e8f3709fba42ce335a0ababe;hb=96a411663168b0ba5432b407a83be55f3df0c802;hp=474f0bc67962fede585b0fd22ae39359e17d01d5;hpb=ce3185de9d9705e259f2b60dd4b5509007fa17d4;p=xscreensaver diff --git a/hacks/halo.c b/hacks/halo.c index 474f0bc6..fc69ea73 100644 --- a/hacks/halo.c +++ b/hacks/halo.c @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 1993, 1995, 1996, 1997 +/* xscreensaver, Copyright (c) 1993, 1995, 1996, 1997, 1998, 1999, 2003 * Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its @@ -126,6 +126,11 @@ init_circles (Display *dpy, Window window) cycle_p = mono_p ? False : get_boolean_resource ("cycle", "Cycle"); + /* If the visual isn't color-indexed, don't bother trying to + allocate writable cells. */ + if (cycle_p && !has_writable_cells (xgwa.screen, xgwa.visual)) + cycle_p = False; + if (mono_p) ; @@ -207,6 +212,8 @@ run_circles (Display *dpy, Window window) static Bool first_time_p = True; Bool done = False; Bool inhibit_sleep = False; + static int clear_tick = 0; + XFillRectangle (dpy, pixmap, erase_gc, 0, 0, width, height); for (i = 0; i < count; i++) { @@ -250,7 +257,7 @@ run_circles (Display *dpy, Window window) if (cycle_p && cmode != seuss_mode) { struct timeval now; - static struct timeval then = { 0, }; + static struct timeval then = { 0, 0 }; unsigned long diff; #ifdef GETTIMEOFDAY_TWO_ARGS struct timezone tzp; @@ -307,25 +314,15 @@ run_circles (Display *dpy, Window window) XSetBackground (dpy, copy_gc, colors [bg_index].pixel); } } -#if 1 /* Sometimes go out from the inside instead of the outside */ - else if ((random () % 10) == 0) + else if (clear_tick == 0 && ((random () % 3) == 0)) { -# if 0 - if (! mono_p) - { - unsigned long swap = fg_index; - fg_index = bg_index; - bg_index = swap; - XSetForeground (dpy, copy_gc, colors [fg_index].pixel); - XSetBackground (dpy, copy_gc, colors [bg_index].pixel); - } -# endif iterations = 0; /* ick */ for (i = 0; i < count; i++) circles [i].radius %= circles [i].increment; + + clear_tick = ((random() % 8) + 4) | 1; /* must be odd */ } -#endif else { oiterations = iterations; @@ -365,7 +362,7 @@ run_circles (Display *dpy, Window window) : (iterations & 1))) { XCopyPlane (dpy, buffer, window, copy_gc, 0, 0, width, height, 0, 0, 1); - XSync (dpy, True); + XSync (dpy, False); if (anim_p && done) XFillRectangle (dpy, buffer, erase_gc, 0, 0, width, height); } @@ -374,7 +371,7 @@ run_circles (Display *dpy, Window window) XCopyPlane (dpy, pixmap, window, copy_gc, 0,0,width,height,width,height, 1); if (buffer) XCopyPlane (dpy, buffer, window, copy_gc, 0,0,width,height,0,height, 1); - XSync (dpy, True); + XSync (dpy, False); #endif if (done) @@ -393,23 +390,39 @@ run_circles (Display *dpy, Window window) if (! (random() % 10)) direction = -1; } - if (done) - really_first_p = False; XSync(dpy, False); + screenhack_handle_events (dpy); if (cycle_p && cycle_delay) { - int i = 0; + i = 0; while (i < d) { rotate_colors (dpy, cmap, colors, ncolors, direction); usleep(cycle_delay); + screenhack_handle_events (dpy); i += cycle_delay; } } + else if (cmode != seuss_mode && + done && !really_first_p && cycle_delay > 0) + usleep (cycle_delay * 50); else - usleep (d); + usleep (d); + + if (done) + really_first_p = False; + } + + if (done && clear_tick > 0) + { + clear_tick--; + if (!clear_tick) + { + XClearWindow (dpy, window); + if (buffer) XFillRectangle (dpy, buffer, erase_gc, 0,0,width,height); + } } } @@ -446,5 +459,8 @@ screenhack (Display *dpy, Window window) { init_circles (dpy, window); while (1) - run_circles (dpy, window); + { + run_circles (dpy, window); + screenhack_handle_events (dpy); + } }