From http://www.jwz.org/xscreensaver/xscreensaver-5.33.tar.gz
[xscreensaver] / hacks / glx / jigsaw.c
index 3ffd08d66effe7ab1b2b6c4695a0b70f12424891..dc7b8c3db654e36527790693a3351d14c776d82a 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1997-2012 Jamie Zawinski <jwz@jwz.org>
+/* xscreensaver, Copyright (c) 1997-2015 Jamie Zawinski <jwz@jwz.org>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -48,7 +48,7 @@
 #define DEF_WOBBLE       "True"
 #define DEF_DEBUG        "False"
 
-#define DEF_FONT "-*-helvetica-bold-r-normal-*-240-*"
+#define DEF_FONT "-*-helvetica-bold-r-normal-*-*-240-*-*-*-*-*-*"
 #define DEFAULTS  "*delay:             20000   \n" \
                  "*showFPS:            False   \n" \
                  "*font:            " DEF_FONT"\n" \
@@ -486,7 +486,7 @@ draw_piece (jigsaw_configuration *jc, puzzle_piece *p,
 
   { GLfloat ss = 1.0 / resolution; glScalef (ss, ss, ss); }
 
-# ifndef HAVE_JWZGLES
+# ifndef HAVE_JWZGLES /* #### glPolygonMode other than GL_FILL unimplemented */
   glPolygonMode (GL_FRONT_AND_BACK, wire ? GL_LINE : GL_FILL);
 # endif
 
@@ -1157,8 +1157,11 @@ loading_msg (ModeInfo *mi)
   jigsaw_configuration *jc = &sps[MI_SCREEN(mi)];
   int wire = MI_IS_WIREFRAME(mi);
   const char *text = "Loading...";
-  int h;
-  int w = texture_string_width (jc->texfont, text, &h);
+  XCharStruct e;
+  int w, h;
+  texture_string_metrics (jc->texfont, text, &e, 0, 0);
+  w = e.width;
+  h = e.ascent + e.descent;
 
   if (wire) return;
 
@@ -1345,53 +1348,16 @@ jigsaw_handle_event (ModeInfo *mi, XEvent *event)
 {
   jigsaw_configuration *jc = &sps[MI_SCREEN(mi)];
 
-  if (event->xany.type == ButtonPress &&
-      event->xbutton.button == Button1)
+  if (gltrackball_event_handler (event, jc->trackball,
+                                 MI_WIDTH (mi), MI_HEIGHT (mi),
+                                 &jc->button_down_p))
+    return True;
+  else if (screenhack_event_helper (MI_DISPLAY(mi), MI_WINDOW(mi), event))
     {
-      jc->button_down_p = True;
-      gltrackball_start (jc->trackball,
-                         event->xbutton.x, event->xbutton.y,
-                         MI_WIDTH (mi), MI_HEIGHT (mi));
+      begin_scatter (mi, False);
+      jc->state = PUZZLE_SCATTER;
       return True;
     }
-  else if (event->xany.type == ButtonRelease &&
-           event->xbutton.button == Button1)
-    {
-      jc->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 (jc->trackball, event->xbutton.button, 10,
-                              !!event->xbutton.state);
-      return True;
-    }
-  else if (event->xany.type == MotionNotify &&
-           jc->button_down_p)
-    {
-      gltrackball_track (jc->trackball,
-                         event->xmotion.x, event->xmotion.y,
-                         MI_WIDTH (mi), MI_HEIGHT (mi));
-      return True;
-    }
-  else if (event->xany.type == KeyPress)
-    {
-      KeySym keysym;
-      char c = 0;
-      XLookupString (&event->xkey, &c, 1, &keysym, 0);
-
-      if (c == ' ' || c == '\t' || c == '\r' || c == '\n')
-        {
-          begin_scatter (mi, False);
-          jc->state = PUZZLE_SCATTER;
-          return True;
-        }
-    }
-
 
   return False;
 }
@@ -1429,7 +1395,7 @@ init_jigsaw (ModeInfo *mi)
       glLightfv(GL_LIGHT0, GL_SPECULAR, spc);
     }
 
-  jc->trackball = gltrackball_init ();
+  jc->trackball = gltrackball_init (False);
   jc->rot = make_rotator (0, 0, 0, 0, speed * 0.002, True);
   jc->texfont = load_texture_font (MI_DISPLAY(mi), "font");