http://ftp.ksu.edu.tw/FTP/FreeBSD/distfiles/xscreensaver-4.23.tar.gz
[xscreensaver] / hacks / glx / gears.c
index 52bdab820adf0e387b4674bacbc9487f0e9c59b3..bd055982f237508dd386f6ac326d9af44fcfe1f9 100644 (file)
@@ -1,9 +1,8 @@
 /* -*- Mode: C; tab-width: 4 -*- */
 /* gears --- 3D gear wheels */
 
-#if !defined( lint ) && !defined( SABER )
+#if 0
 static const char sccsid[] = "@(#)gears.c      4.07 97/11/24 xlockmore";
-
 #endif
 
 /*-
@@ -35,13 +34,6 @@ static const char sccsid[] = "@(#)gears.c    4.07 97/11/24 xlockmore";
  * been fixed in MesaGL 2.2 and later releases.
  */
 
-/*-
- * due to a Bug/feature in VMS X11/Intrinsic.h has to be placed before xlock.
- * otherwise caddr_t is not defined correctly
- */
-
-#include <X11/Intrinsic.h>
-
 #ifdef STANDALONE
 # define PROGCLASS                                     "Gears"
 # define HACK_INIT                                     init_gears
@@ -53,7 +45,6 @@ static const char sccsid[] = "@(#)gears.c     4.07 97/11/24 xlockmore";
 # define DEFAULTS      "*count:                1       \n"                     \
                                        "*cycles:               2       \n"                     \
                                        "*delay:                20000   \n"                     \
-                                       "*planetary:    False   \n"                     \
                                        "*showFPS:      False   \n"                     \
                                        "*wireframe:    False   \n"
 # include "xlockmore.h"                                /* from the xscreensaver distribution */
@@ -70,16 +61,21 @@ static const char sccsid[] = "@(#)gears.c   4.07 97/11/24 xlockmore";
 #define countof(x) (sizeof((x))/sizeof((*x)))
 
 #define DEF_PLANETARY "False"
+#define DEF_SPIN "True"
 
 static int planetary;
+static int spin;
 
 static XrmOptionDescRec opts[] = {
-  {"-planetary", ".gears.planetary", XrmoptionNoArg, (caddr_t) "true" },
-  {"+planetary", ".gears.planetary", XrmoptionNoArg, (caddr_t) "false" },
+  {"-planetary", ".gears.planetary", XrmoptionNoArg, "true" },
+  {"+planetary", ".gears.planetary", XrmoptionNoArg, "false" },
+  {"-spin", ".gears.spin", XrmoptionNoArg, "true" },
+  {"+spin", ".gears.spin", XrmoptionNoArg, "false" },
 };
 
 static argtype vars[] = {
-  {(caddr_t *) &planetary, "planetary", "Planetary", DEF_PLANETARY, t_Bool},
+  {&planetary, "planetary", "Planetary", DEF_PLANETARY, t_Bool},
+  {&spin, "spin", "Spin", DEF_SPIN, t_Bool},
 };
 
 ModeSpecOpt gears_opts = {countof(opts), opts, countof(vars), vars, NULL};
@@ -544,13 +540,14 @@ draw(ModeInfo * mi)
 
     gltrackball_rotate (gp->trackball);
 
-    {
-      double x, y, z;
-      get_rotation (gp->rot, &x, &y, &z, !gp->button_down_p);
-      glRotatef (x * 360, 1.0, 0.0, 0.0);
-      glRotatef (y * 360, 0.0, 1.0, 0.0);
-      glRotatef (z * 360, 0.0, 0.0, 1.0);
-    }
+    if (spin)
+         {
+               double x, y, z;
+               get_rotation (gp->rot, &x, &y, &z, !gp->button_down_p);
+               glRotatef (x * 360, 1.0, 0.0, 0.0);
+               glRotatef (y * 360, 0.0, 1.0, 0.0);
+               glRotatef (z * 360, 0.0, 0.0, 1.0);
+         }
 
     if (!planetary) {
       glPushMatrix();
@@ -927,7 +924,7 @@ gears_handle_event (ModeInfo *mi, XEvent *event)
   gearsstruct *gp = &gears[MI_SCREEN(mi)];
 
   if (event->xany.type == ButtonPress &&
-      event->xbutton.button & Button1)
+      event->xbutton.button == Button1)
     {
       gp->button_down_p = True;
       gltrackball_start (gp->trackball,
@@ -936,11 +933,19 @@ gears_handle_event (ModeInfo *mi, XEvent *event)
       return True;
     }
   else if (event->xany.type == ButtonRelease &&
-           event->xbutton.button & Button1)
+           event->xbutton.button == Button1)
     {
       gp->button_down_p = False;
       return True;
     }
+  else if (event->xany.type == ButtonPress &&
+           (event->xbutton.button == Button4 ||
+            event->xbutton.button == Button5))
+    {
+      gltrackball_mousewheel (gp->trackball, event->xbutton.button, 10,
+                              !!event->xbutton.state);
+      return True;
+    }
   else if (event->xany.type == MotionNotify &&
            gp->button_down_p)
     {