From http://www.jwz.org/xscreensaver/xscreensaver-5.30.tar.gz
[xscreensaver] / hacks / glx / flipflop.c
index ec20898f12af041705be1c5f0b86bc5b030ef484..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;
 }
@@ -265,6 +249,8 @@ display(Flipflopcreen *c)
     glLightfv(GL_LIGHT0, GL_AMBIENT, amb);
 
 
+    glRotatef(current_device_rotation(), 0, 0, 1);
+
     /** setup perspectif */
     glTranslatef(0.0, 0.0, -c->reldist*board_avg_size);
     glRotatef(22.5, 1.0, 0.0, 0.0);  
@@ -403,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;
@@ -419,8 +405,6 @@ init_flipflop(ModeInfo *mi)
     c->sheet = (randsheet*) malloc(sizeof(randsheet)); 
     randsheet_create( c->sheet ); 
 
-    glClearColor(0.0, 0.0, 0.0, 0.0);
-
     clearbits = GL_COLOR_BUFFER_BIT;
 
     glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);