/* modified from a module from the xscreensaver distribution */
/*
- * xscreensaver, Copyright (c) 1992, 1993, 1994, 1996, 1997, 1998
+ * xscreensaver, Copyright (c) 1992, 1993, 1994, 1996, 1997, 1998, 2005
* Jamie Zawinski <jwz@jwz.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
static int x, y, s; /* x & y coords of buffer (upper left corner) */
/* s is the width of the buffer */
+static int off = 0; /* random offset from currentTimeInMs(), so that
+ two concurrent copies of spotlight have different
+ behavior. */
+
static int oldx, oldy, max_x_speed, max_y_speed;
/* used to keep the new buffer position
over the old spotlight image to make sure
#endif
window_gc = XCreateGC(dpy, window, gcflags, &gcv);
-
- /* grab screen to window */
- grab_screen_image(xgwa.screen, window);
-
- /* save screen to pixmap for copying later */
+ /* grab screen to pixmap */
pm = XCreatePixmap(dpy, window, sizex, sizey, xgwa.depth);
- XCopyArea(dpy, window, pm, window_gc, 0, 0, sizex, sizey, 0, 0);
-
+ load_random_image (xgwa.screen, window, pm, NULL, NULL);
+ XClearWindow(dpy, window);
+ XFlush (dpy);
/* create buffer to reduce flicker */
buffer = XCreatePixmap(dpy, window, sizex, sizey, xgwa.depth);
/* avoid remants */
max_x_speed = max_y_speed = radius;
+
+ off = random();
#ifdef DEBUG
/* create GC with white fg */
gcv.foreground = fg;
white_gc = XCreateGC(dpy, window, gcflags, &gcv);
#endif
-
- /* initialize x and y to avoid initial `jump' across screen */
- x = ((1 + sin(((float)currentTimeInMs()) / X_PERIOD * 2. * M_PI))/2.0)
- * (sizex - s/2) -s/4 + MINX;
- y = ((1 + sin(((float)currentTimeInMs()) / Y_PERIOD * 2. * M_PI))/2.0)
- * (sizey - s/2) -s/4 + MINY;
-
}
* perform one iteration
*/
static void
-onestep (Display *dpy, Window window)
+onestep (Display *dpy, Window window, Bool first_p)
{
long now;
s = radius *4 ; /* s = width of buffer */
- now = currentTimeInMs();
+ now = currentTimeInMs() + off;
/* find new x,y */
x = ((1 + sin(((float)now) / X_PERIOD * 2. * M_PI))/2.0)
y = ((1 + sin(((float)now) / Y_PERIOD * 2. * M_PI))/2.0)
* (sizey - s/2) -s/4 + MINY;
- /* limit change in x and y to buffer width */
- if ( x < (oldx - max_x_speed) ) x = oldx - max_x_speed;
- if ( x > (oldx + max_x_speed) ) x = oldx + max_x_speed;
- if ( y < (oldy - max_y_speed) ) y = oldy - max_y_speed;
- if ( y > (oldy + max_y_speed) ) y = oldy + max_y_speed;
+ if (!first_p)
+ {
+ /* limit change in x and y to buffer width */
+ if ( x < (oldx - max_x_speed) ) x = oldx - max_x_speed;
+ if ( x > (oldx + max_x_speed) ) x = oldx + max_x_speed;
+ if ( y < (oldy - max_y_speed) ) y = oldy - max_y_speed;
+ if ( y > (oldy + max_y_speed) ) y = oldy + max_y_speed;
+ }
/* copy area of screen image (pm) to buffer
Clip to a circle */
void
screenhack (Display *dpy, Window window)
{
+ Bool first_p = True;
init_hack (dpy, window);
while (1) {
- onestep(dpy, window);
+ onestep(dpy, window, first_p);
+ first_p = False;
XSync(dpy, False);
if (delay) usleep (delay);
screenhack_handle_events (dpy);