From http://www.jwz.org/xscreensaver/xscreensaver-5.37.tar.gz
[xscreensaver] / hacks / glx / pipes.c
index 9ca14d2453d880836bcc1be91bcb609dee343e3c..77be33e1fce2ed41c40b4ea451b4e3f0aea39df0 100644 (file)
@@ -65,9 +65,11 @@ static const char sccsid[] = "@(#)pipes.c    4.07 97/11/24 xlockmore";
                                        "*size:                 500     \n"                     \
                        "*showFPS:      False   \n"                 \
                        "*fpsSolid:     True    \n"                 \
-                       "*wireframe:    False   \n"
+                       "*wireframe:    False   \n"                 \
+                                       "*suppressRotationAnimation: True\n" \
 
 # define refresh_pipes 0
+# define release_pipes 0
 # include "xlockmore.h"                                /* from the xscreensaver distribution */
 #else  /* !STANDALONE */
 # include "xlock.h"                                    /* from the xlockmore distribution */
@@ -75,7 +77,7 @@ static const char sccsid[] = "@(#)pipes.c     4.07 97/11/24 xlockmore";
 
 #ifdef USE_GL
 
-#ifdef HAVE_COCOA
+#ifdef HAVE_JWXYZ
 # include "jwxyz.h"
 #else
 # include <X11/Xlib.h>
@@ -131,7 +133,7 @@ ENTRYPOINT ModeSpecOpt pipes_opts =
 
 #ifdef USE_MODULES
 ModStruct   pipes_description =
-{"pipes", "init_pipes", "draw_pipes", "release_pipes",
+{"pipes", "init_pipes", "draw_pipes", NULL,
  "draw_pipes",
  "change_pipes", NULL, &pipes_opts,
  1000, 2, 5, 500, 4, 1.0, "",
@@ -669,37 +671,13 @@ pipes_handle_event (ModeInfo *mi, XEvent *event)
 {
   pipesstruct *pp = &pipes[MI_SCREEN(mi)];
 
-  if (event->xany.type == ButtonPress &&
-      event->xbutton.button == Button1)
+  if (gltrackball_event_handler (event, pp->trackball,
+                                 MI_WIDTH (mi), MI_HEIGHT (mi),
+                                 &pp->button_down_p))
+    return True;
+  else if (screenhack_event_helper (MI_DISPLAY(mi), MI_WINDOW(mi), event))
     {
-      pp->button_down_p = True;
-      gltrackball_start (pp->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)
-    {
-      pp->button_down_p = False;
-      return True;
-    }
-  else if (event->xany.type == ButtonPress &&
-           (event->xbutton.button == Button4 ||
-            event->xbutton.button == Button5 ||
-            event->xbutton.button == Button6 ||
-            event->xbutton.button == Button7))
-    {
-      gltrackball_mousewheel (pp->trackball, event->xbutton.button, 10,
-                              !!event->xbutton.state);
-      return True;
-    }
-  else if (event->xany.type == MotionNotify &&
-           pp->button_down_p)
-    {
-      gltrackball_track (pp->trackball,
-                         event->xmotion.x, event->xmotion.y,
-                         MI_WIDTH (mi), MI_HEIGHT (mi));
+      pp->fadeout = 100;
       return True;
     }
 
@@ -711,17 +689,15 @@ pipes_handle_event (ModeInfo *mi, XEvent *event)
 static void generate_system (ModeInfo *);
 
 
+static void free_pipes (ModeInfo *);
+
 ENTRYPOINT void
 init_pipes (ModeInfo * mi)
 {
        int         screen = MI_SCREEN(mi);
        pipesstruct *pp;
 
-       if (pipes == NULL) {
-               if ((pipes = (pipesstruct *) calloc(MI_NUM_SCREENS(mi),
-                                             sizeof (pipesstruct))) == NULL)
-                       return;
-       }
+       MI_INIT (mi, pipes, free_pipes);
        pp = &pipes[screen];
 
        pp->window = MI_WINDOW(mi);
@@ -773,7 +749,7 @@ init_pipes (ModeInfo * mi)
                MI_CLEARWINDOW(mi);
        }
 
-    pp->trackball = gltrackball_init ();
+    pp->trackball = gltrackball_init (True);
     generate_system (mi);
 }
 
@@ -1135,10 +1111,7 @@ draw_pipes (ModeInfo * mi)
 
        glTranslatef(0.0, 0.0, fisheye ? -3.8 : -4.8);
 
-    /* Do it twice because we don't track the device's orientation. */
-    glRotatef( current_device_rotation(), 0, 0, 1);
     gltrackball_rotate (pp->trackball);
-    glRotatef(-current_device_rotation(), 0, 0, 1);
 
        if (rotatepipes)
       glRotatef(pp->initial_rotation, 0.0, 1.0, 0.0);
@@ -1194,57 +1167,47 @@ change_pipes (ModeInfo * mi)
 #endif /* !STANDALONE */
 
 
-ENTRYPOINT void
-release_pipes (ModeInfo * mi)
+static void
+free_pipes (ModeInfo * mi)
 {
-       if (pipes != NULL) {
-               int         screen;
-
-               for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) {
-                       pipesstruct *pp = &pipes[screen];
-
-                       if (pp->glx_context) {
-
-                               /* Display lists MUST be freed while their glXContext is current. */
-                               glXMakeCurrent(MI_DISPLAY(mi), pp->window, *(pp->glx_context));
-
-                               if (pp->valve)
-                                       glDeleteLists(pp->valve, 1);
-                               if (pp->bolts)
-                                       glDeleteLists(pp->bolts, 1);
-                               if (pp->betweenbolts)
-                                       glDeleteLists(pp->betweenbolts, 1);
-
-                               if (pp->elbowbolts)
-                                       glDeleteLists(pp->elbowbolts, 1);
-                               if (pp->elbowcoins)
-                                       glDeleteLists(pp->elbowcoins, 1);
-
-                               if (pp->guagehead)
-                                       glDeleteLists(pp->guagehead, 1);
-                               if (pp->guageface)
-                                       glDeleteLists(pp->guageface, 1);
-                               if (pp->guagedial)
-                                       glDeleteLists(pp->guagedial, 1);
-                               if (pp->guageconnector)
-                                       glDeleteLists(pp->guageconnector, 1);
-                               if (pp->teapot)
-                                       glDeleteLists(pp->teapot, 1);
-                if (pp->dlists)
-                  {
-                    int i;
-                    for (i = 0; i < pp->dlist_count; i++)
-                      glDeleteLists (pp->dlists[i], 1);
-                    free (pp->dlists);
-                    free (pp->poly_counts);
-                  }
-                       }
-               }
+       pipesstruct *pp = &pipes[MI_SCREEN(mi)];
 
-               (void) free((void *) pipes);
-               pipes = NULL;
+       if (pp->glx_context) {
+
+               /* Display lists MUST be freed while their glXContext is current. */
+               glXMakeCurrent(MI_DISPLAY(mi), pp->window, *(pp->glx_context));
+
+               if (pp->valve)
+                       glDeleteLists(pp->valve, 1);
+               if (pp->bolts)
+                       glDeleteLists(pp->bolts, 1);
+               if (pp->betweenbolts)
+                       glDeleteLists(pp->betweenbolts, 1);
+
+               if (pp->elbowbolts)
+                       glDeleteLists(pp->elbowbolts, 1);
+               if (pp->elbowcoins)
+                       glDeleteLists(pp->elbowcoins, 1);
+
+               if (pp->guagehead)
+                       glDeleteLists(pp->guagehead, 1);
+               if (pp->guageface)
+                       glDeleteLists(pp->guageface, 1);
+               if (pp->guagedial)
+                       glDeleteLists(pp->guagedial, 1);
+               if (pp->guageconnector)
+                       glDeleteLists(pp->guageconnector, 1);
+               if (pp->teapot)
+                       glDeleteLists(pp->teapot, 1);
+        if (pp->dlists)
+          {
+            int i;
+            for (i = 0; i < pp->dlist_count; i++)
+              glDeleteLists (pp->dlists[i], 1);
+            free (pp->dlists);
+            free (pp->poly_counts);
+          }
        }
-       FreeAllGL(mi);
 }
 
 XSCREENSAVER_MODULE ("Pipes", pipes)