From http://www.jwz.org/xscreensaver/xscreensaver-5.37.tar.gz
[xscreensaver] / hacks / glx / endgame.c
index b4811da455cae932495870203c4f10a8d4d650b8..e69a21c0ec3bbcfad70570ee2ebb1c9e55f55a0f 100644 (file)
@@ -21,6 +21,7 @@
                       "*wireframe: False \n" \
 
 # define refresh_chess 0
+# define release_chess 0
 # include "xlockmore.h"
 
 #else
@@ -73,7 +74,7 @@ ENTRYPOINT ModeSpecOpt chess_opts = {countof(opts), opts, countof(vars), vars, N
 
 #ifdef USE_MODULES
 ModStruct   chess_description =
-{"chess", "init_chess", "draw_chess", "release_chess",
+{"chess", "init_chess", "draw_chess", NULL,
  "draw_chess", "init_chess", NULL, &chess_opts,
  1000, 1, 2, 1, 4, 1.0, "",
  "Chess", 0, NULL};
@@ -204,35 +205,16 @@ ENTRYPOINT Bool chess_handle_event (ModeInfo *mi, XEvent *event)
 {
   Chesscreen *cs = &qs[MI_SCREEN(mi)];
 
-  if(event->xany.type == ButtonPress && event->xbutton.button == Button1) {
-    cs->button_down_p = True;
-    gltrackball_start (cs->trackball,
-                      event->xbutton.x, event->xbutton.y,
-                      MI_WIDTH (mi), MI_HEIGHT (mi));
+  if (gltrackball_event_handler (event, cs->trackball,
+                                 MI_WIDTH (mi), MI_HEIGHT (mi),
+                                 &cs->button_down_p))
     return True;
-  }
-  else if(event->xany.type == ButtonRelease 
-         && event->xbutton.button == Button1) {
-    cs->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))
+  else if (screenhack_event_helper (MI_DISPLAY(mi), MI_WINDOW(mi), event))
     {
-      gltrackball_mousewheel (cs->trackball, event->xbutton.button, 5,
-                              !event->xbutton.state);
+      cs->done = 1;
       return True;
     }
-  else if(event->xany.type == MotionNotify && cs->button_down_p) {
-    gltrackball_track (cs->trackball,
-                      event->xmotion.x, event->xmotion.y,
-                      MI_WIDTH (mi), MI_HEIGHT (mi));
-    return True;
-  }
-  
   return False;
 }
 
@@ -818,14 +800,12 @@ ENTRYPOINT void init_chess(ModeInfo *mi)
   Chesscreen *cs;
   int screen = MI_SCREEN(mi);
 
-  if(!qs && 
-     !(qs = (Chesscreen *) calloc(MI_NUM_SCREENS(mi), sizeof(Chesscreen))))
-    return;
+  MI_INIT(mi, qs, NULL);
   
   cs = &qs[screen];
   cs->window = MI_WINDOW(mi);
   cs->wire = MI_IS_WIREFRAME(mi);
-  cs->trackball = gltrackball_init ();
+  cs->trackball = gltrackball_init (False);
   
   cs->oldwhite = -1;
 
@@ -978,16 +958,6 @@ ENTRYPOINT void draw_chess(ModeInfo *mi)
   glXSwapBuffers(disp, w);
 }
 
-/** bust it */
-ENTRYPOINT void release_chess(ModeInfo *mi) 
-{
-  if(qs)
-    free((void *) qs);
-  qs = 0;
-
-  FreeAllGL(mi);
-}
-
 XSCREENSAVER_MODULE_2 ("Endgame", endgame, chess)
 
 #endif