ftp://ftp.krokus.ru/pub/OpenBSD/distfiles/xscreensaver-4.22.tar.gz
[xscreensaver] / hacks / glx / klein.c
index b068e3f4e7ff8259be004e41437ea1b78e9d9730..2329170475568a7104434f532e86feb35a5a5f10 100644 (file)
  *
  */
 
-/*-
- * 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                                     "Klein"
 # define HACK_INIT                                     init_klein
 #define DEF_RANDOM                             "False"
 #define DEF_SPEED                              "150"
 
-# define DEFAULTS                                      "*delay:                20000   \n"                     \
-                                                                       "*showFPS:      False   \n"                     \
-                                                                       "*wireframe:    False   \n"                     \
-                                                                       "*random:          " DEF_RANDOM     "\n"        \
-                                                                       "*speed:           " DEF_SPEED     "\n" \
-                                                                       "*spin:        " DEF_SPIN      "\n" \
-                                                                       "*wander:      " DEF_WANDER    "\n" \
+# define DEFAULTS                                      "*delay:                20000   \n" \
+                                                                       "*showFPS:      False   \n"
 
 # include "xlockmore.h"                /* from the xscreensaver distribution */
 #else  /* !STANDALONE */
@@ -64,7 +52,7 @@ enum {
        SEASHELL,
        SWALLOWTAIL,
        BOHEM,
-    SURFACE_LAST,
+    SURFACE_LAST
 };
 
 /* primitives to draw with 
@@ -78,7 +66,7 @@ enum {
        MY_POINTS = 0,
        MY_LINES,
        MY_LINE_LOOP,
-       MY_PRIM_LAST,
+       MY_PRIM_LAST
 };
 
 
@@ -89,7 +77,7 @@ static Bool do_spin;
 static Bool do_wander;
 
 static XrmOptionDescRec opts[] = {
-  {"-speed",   ".speed",    XrmoptionSepArg, (caddr_t) 0 },
+  {"-speed",   ".speed",    XrmoptionSepArg, 0 },
   { "-spin",   ".spin",   XrmoptionNoArg, "True" },
   { "+spin",   ".spin",   XrmoptionNoArg, "False" },
   { "-wander", ".wander", XrmoptionNoArg, "True" },
@@ -99,10 +87,10 @@ static XrmOptionDescRec opts[] = {
 };
 
 static argtype vars[] = {
-  {(caddr_t *) &rand,   "rand",   "Random",   DEF_RANDOM,   t_Bool},
-  {(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_Int},
+  {&rand,      "rand",   "Random", DEF_RANDOM, t_Bool},
+  {&do_spin,   "spin",   "Spin",   DEF_SPIN,   t_Bool},
+  {&do_wander, "wander", "Wander", DEF_WANDER, t_Bool},
+  {&speed,     "speed",  "Speed",  DEF_SPEED,  t_Int},
 };
 
 
@@ -307,14 +295,20 @@ klein_handle_event (ModeInfo *mi, XEvent *event)
 {
        kleinstruct *kp = &klein[MI_SCREEN(mi)];
 
-       if (event->xany.type == ButtonPress && event->xbutton.button & Button1) {
+       if (event->xany.type == ButtonPress && event->xbutton.button == Button1) {
                        kp->button_down_p = True;
                        gltrackball_start (kp->trackball, event->xbutton.x, event->xbutton.y, MI_WIDTH (mi), MI_HEIGHT (mi));
                        return True;
-       } else if (event->xany.type == ButtonRelease && event->xbutton.button & Button1) {
+       } else if (event->xany.type == ButtonRelease && event->xbutton.button == Button1) {
                        kp->button_down_p = False;
                        return True;
-       } else if (event->xany.type == MotionNotify && kp->button_down_p) {
+       } else if (event->xany.type == ButtonPress &&
+               (event->xbutton.button == Button4 ||
+                event->xbutton.button == Button5)) {
+      gltrackball_mousewheel (kp->trackball, event->xbutton.button, 10,
+                              !!event->xbutton.state);
+      return True;
+    } else if (event->xany.type == MotionNotify && kp->button_down_p) {
                        gltrackball_track (kp->trackball, event->xmotion.x, event->xmotion.y, MI_WIDTH (mi), MI_HEIGHT (mi));
                        return True;
        }