#!/afs/athena/contrib/perl/perl


$SIG{'INT'} = 'sighandler';
$SIG{'HUP'} = 'sighandler';
$SIG{'QUIT'} = 'sighandler';

do "./xbase.perl";
$window = $ENV{'WINDOWID'};
int($window);
$x = 100;
$e = .95;
$y =100;
$vx = 8;
$vy = -1;
$xwinfo=`xwininfo -id $window`;
$xwinfo =~ /Width: (\d+)/;
$width = int($1);
$xwinfo =~ /Height: (\d+)/;
$height = int($1);
print &xlib'x_open_display($ENV{'DISPLAY'});
while(($vy > .015 || $vy < -.015) || $y != ($xlib'rooth-100)){
    $x = ($x + $vx);
$y = ($y + $vy);
#print("$x, $y\n");
 
&xlib'x_configure($window, 15, $x, $y, $width, $height);
    if($x > ($xlib'rootw - $width)){$vx = -$vx;$x = ($xlib'rootw - $width);$vx *= $e;}
    if($x < 0) { $vx = -$vx;$x = 0;$vx *= $e;}
    if($y > ($xlib'rooth - $height)){$vy = -$vy;$y = $xlib'rooth - $height;$vy *= $e;}
    if($y < 0) { $vy = -$vy;$y = 0;$vy *= $e;}
    $vy += .03;
    if($y > ($xlib'rooth + 50 )){exit(1);}
$events++;
if($events == 400){$events = 0;sleep(2);} 
#print("($x, $y), ");
#print("$vy, ");
}
#print &xlib'x_move_window($window, 100, 100);
sleep(1);



sub sighandler {
    print("Quitting cleanly... \n");
    exit(0);
}
