From http://www.jwz.org/xscreensaver/xscreensaver-5.35.tar.gz
[xscreensaver] / hacks / glx / antmaze.c
index 0f18e15fe8dc9f49843dccb276e2fb05012f5c98..a66c4b5c0b6b3a1741a606beabc5d1d42394566a 100644 (file)
@@ -31,7 +31,7 @@ static const char sccsid[] = "@(#)antmaze.c   5.01 2001/03/01 xlockmore";
 # include "xlock.h"            /* from the xlockmore distribution */
 #endif /* !STANDALONE */
 
-#ifdef HAVE_COCOA
+#ifdef HAVE_JWXYZ
 # include "jwxyz.h"
 #else
 # include <X11/Xlib.h>
@@ -1304,55 +1304,30 @@ ENTRYPOINT Bool antmaze_handle_event (ModeInfo *mi, XEvent *event)
 {
   antmazestruct *mp = &antmaze[MI_SCREEN(mi)];
 
-  switch(event->xany.type) {
-  case ButtonPress:
+  if (gltrackball_event_handler (event, mp->trackball,
+                                 MI_WIDTH (mi), MI_HEIGHT (mi),
+                                 &mp->button_down_p))
+    return True;
 
-    switch(event->xbutton.button) {
-
-    case Button1:
-      mp->button_down_p = True;
-      gltrackball_start(mp->trackball, 
-                       event->xbutton.x, event->xbutton.y,
-                       MI_WIDTH (mi), MI_HEIGHT (mi));
-      break;
+  if (event->xany.type == ButtonPress)
+    {
+      switch(event->xbutton.button) {
 
-    case Button3:
-      mp->focus = (mp->focus + 1) % ANTCOUNT;
-      break;
+      case Button3:
+        mp->focus = (mp->focus + 1) % ANTCOUNT;
+        return True;
       
-    case Button4:
-      mp->mag = max(mp->mag-1, 1);
-      break;
-
-    case Button5:
-      mp->mag = min(mp->mag+1, MAX_MAGNIFICATION);
-      break;
-    }
+      case Button4:
+        mp->mag = max(mp->mag-1, 1);
+        return True;
 
-    break;
-    
-  case ButtonRelease:
-
-    switch(event->xbutton.button) {
-    case Button1:
-      mp->button_down_p = False;
-      break;
+      case Button5:
+        mp->mag = min(mp->mag+1, MAX_MAGNIFICATION);
+        return True;
+      }
     }
 
-    break;
-
-  case MotionNotify:
-    if(mp->button_down_p)
-      gltrackball_track(mp->trackball,
-                       event->xmotion.x, event->xmotion.y,
-                       MI_WIDTH (mi), MI_HEIGHT (mi));
-    break;
-    
-  default:
-    return False;
-  }
-
-  return True;
+  return False;
 }
 
 ENTRYPOINT void init_antmaze(ModeInfo * mi) 
@@ -1433,7 +1408,7 @@ ENTRYPOINT void init_antmaze(ModeInfo * mi)
   mp->mag = 4.0;
 
   mp->rot = make_rotator (rot_speed, rot_speed, rot_speed, 1, 0, True);
-  mp->trackball = gltrackball_init ();
+  mp->trackball = gltrackball_init (False);
   
   if ((mp->glx_context = init_GL(mi)) != NULL) {
     reshape_antmaze(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
@@ -1447,6 +1422,7 @@ ENTRYPOINT void init_antmaze(ModeInfo * mi)
 static void
 device_rotate(ModeInfo *mi)
 {
+#if 0
   GLfloat rot = current_device_rotation();
   glRotatef(rot, 0, 0, 1);
   if ((rot >  45 && rot <  135) ||
@@ -1455,6 +1431,7 @@ device_rotate(ModeInfo *mi)
       GLfloat s = MI_HEIGHT(mi) / (GLfloat) MI_WIDTH(mi);
       glScalef (1/s, s, 1);
     }
+#endif
 }