http://ftp.ksu.edu.tw/FTP/FreeBSD/distfiles/xscreensaver-4.20.tar.gz
[xscreensaver] / hacks / glx / dangerball.c
index 6f3f9d46808a2a88098414c50363ded4e86b8ff8..31a67419865b107730efc7ba30850bf23b5232ce 100644 (file)
@@ -1,4 +1,4 @@
-/* dangerball, Copyright (c) 2001, 2002 Jamie Zawinski <jwz@jwz.org>
+/* dangerball, Copyright (c) 2001-2004 Jamie Zawinski <jwz@jwz.org>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -89,9 +89,9 @@ static XrmOptionDescRec opts[] = {
 };
 
 static argtype vars[] = {
-  {(caddr_t *) &do_spin,   "spin",   "Spin",   DEF_SPIN,   t_Bool},
-  {(caddr_t *) &do_wander, "wander", "Wander", DEF_WANDER, t_Bool},
-  {(caddr_t *) &speed,     "speed",  "Speed",  DEF_SPEED,  t_Float},
+  {&do_spin,   "spin",   "Spin",   DEF_SPIN,   t_Bool},
+  {&do_wander, "wander", "Wander", DEF_WANDER, t_Bool},
+  {&speed,     "speed",  "Speed",  DEF_SPEED,  t_Float},
 };
 
 ModeSpecOpt sws_opts = {countof(opts), opts, countof(vars), vars, NULL};
@@ -196,7 +196,7 @@ ball_handle_event (ModeInfo *mi, XEvent *event)
   ball_configuration *bp = &bps[MI_SCREEN(mi)];
 
   if (event->xany.type == ButtonPress &&
-      event->xbutton.button & Button1)
+      event->xbutton.button == Button1)
     {
       bp->button_down_p = True;
       gltrackball_start (bp->trackball,
@@ -205,11 +205,19 @@ ball_handle_event (ModeInfo *mi, XEvent *event)
       return True;
     }
   else if (event->xany.type == ButtonRelease &&
-           event->xbutton.button & Button1)
+           event->xbutton.button == Button1)
     {
       bp->button_down_p = False;
       return True;
     }
+  else if (event->xany.type == ButtonPress &&
+           (event->xbutton.button == Button4 ||
+            event->xbutton.button == Button5))
+    {
+      gltrackball_mousewheel (bp->trackball, event->xbutton.button, 10,
+                              !!event->xbutton.state);
+      return True;
+    }
   else if (event->xany.type == MotionNotify &&
            bp->button_down_p)
     {
@@ -266,7 +274,7 @@ init_ball (ModeInfo *mi)
 
   {
     double spin_speed   = 10.0;
-    double wander_speed = 0.15;
+    double wander_speed = 0.12;
     double spin_accel   = 2.0;
 
     bp->rot = make_rotator (do_spin ? spin_speed : 0,
@@ -296,7 +304,7 @@ init_ball (ModeInfo *mi)
   glNewList (bp->spike_list, GL_COMPILE);
   cone (0, 0, 0,
         0, 1, 0,
-        1, 0, SPIKE_FACES, SMOOTH_SPIKES, wire);
+        1, 0, SPIKE_FACES, SMOOTH_SPIKES, False, wire);
   glEndList ();
 
   randomize_spikes (mi);