- /* 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 */
- XSetClipOrigin(dpy, buffer_gc, x,y);
- XCopyArea(dpy, pm, buffer, buffer_gc, x, y, s, s, x, y);
- /* copy buffer to screen (window) */
- XCopyArea(dpy, buffer, window, window_gc, x , y, s, s, x, y);
+ if (!st->first_p)
+ {
+ /* limit change in x and y to buffer width */
+ if ( st->x < (st->oldx - st->max_x_speed) ) st->x = st->oldx - st->max_x_speed;
+ if ( st->x > (st->oldx + st->max_x_speed) ) st->x = st->oldx + st->max_x_speed;
+ if ( st->y < (st->oldy - st->max_y_speed) ) st->y = st->oldy - st->max_y_speed;
+ if ( st->y > (st->oldy + st->max_y_speed) ) st->y = st->oldy + st->max_y_speed;
+ }
+
+ if (! st->buffer)
+ {
+ XClearWindow (st->dpy, st->window);
+ XSetClipOrigin(st->dpy, st->buffer_gc, st->x,st->y);
+ XCopyArea(st->dpy, st->pm, st->window, st->buffer_gc, st->x, st->y, st->s, st->s, st->x, st->y);
+ }
+ else
+ {
+ /* clear buffer */
+ XFillRectangle(st->dpy, st->buffer, st->buffer_gc, st->x, st->y, st->s, st->s);
+
+ /* copy area of screen image (pm) to buffer
+ Clip to a circle */
+ XSetClipOrigin(st->dpy, st->buffer_gc, st->x,st->y);
+ XCopyArea(st->dpy, st->pm, st->buffer, st->buffer_gc, st->x, st->y, st->s, st->s, st->x, st->y);
+
+ /* copy buffer to screen (window) */
+ XCopyArea(st->dpy, st->buffer, st->window, st->window_gc, st->x , st->y, st->s, st->s, st->x, st->y);
+ }