From http://www.jwz.org/xscreensaver/xscreensaver-5.30.tar.gz
[xscreensaver] / hacks / glx / flipflop.c
index 0d534e53785b81fc5bb92cf48fb35acdcc3fbaa9..d780348c8c7bdba88417aa1e20984b612f815478 100644 (file)
@@ -193,44 +193,28 @@ setup_lights(void)
     glEnable(GL_LIGHT0);
 }
 
+static void get_texture(ModeInfo *);
+
+
 ENTRYPOINT Bool
 flipflop_handle_event (ModeInfo *mi, XEvent *event)
 {
     Flipflopcreen *c = &qs[MI_SCREEN(mi)];
 
-    if (event->xany.type == ButtonPress &&
-        event->xbutton.button == Button1)
-        {
-            c->button_down_p = True;
-            gltrackball_start (c->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)
-        {
-            c->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 (c->trackball, event->xbutton.button, 5,
-                                    !event->xbutton.state);
-            return True;
-        }
-    else if (event->xany.type == MotionNotify &&
-             c->button_down_p)
+  if (gltrackball_event_handler (event, c->trackball,
+                                 MI_WIDTH (mi), MI_HEIGHT (mi),
+                                 &c->button_down_p))
+    return True;
+  else if (screenhack_event_helper (MI_DISPLAY(mi), MI_WINDOW(mi), event))
+    {
+      if (!textured || c->got_texture)
         {
-            gltrackball_track (c->trackball,
-                               event->xmotion.x, event->xmotion.y,
-                               MI_WIDTH (mi), MI_HEIGHT (mi));
-            return True;
+          textured = 1;
+          c->got_texture = False;
+          get_texture (mi);
+          return True;
         }
+    }
 
     return False;
 }
@@ -270,9 +254,7 @@ display(Flipflopcreen *c)
     /** setup perspectif */
     glTranslatef(0.0, 0.0, -c->reldist*board_avg_size);
     glRotatef(22.5, 1.0, 0.0, 0.0);  
-    glRotatef(-current_device_rotation(), 0, 0, 1);
     gltrackball_rotate (c->trackball);
-    glRotatef(current_device_rotation(), 0, 0, 1);
     glRotatef(c->theta*100, 0.0, 1.0, 0.0);
     glTranslatef(-0.5*board_x_size, 0.0, -0.5*board_y_size); /* Center the board */
 
@@ -407,7 +389,7 @@ init_flipflop(ModeInfo *mi)
 
     c = &qs[screen];
     c->window = MI_WINDOW(mi);
-    c->trackball = gltrackball_init ();
+    c->trackball = gltrackball_init (False);
 
     c->flipspeed = 0.03;
     c->reldist = 1;