From http://www.jwz.org/xscreensaver/xscreensaver-5.30.tar.gz
[xscreensaver] / hacks / glx / gltext.c
index 070a4e33d49d10c67561fb3d9f18d20bdcf6c11a..8f96e79a1d3bb37a8a8471fd1c08f87fcc02b969 100644 (file)
@@ -1,4 +1,4 @@
-/* gltext, Copyright (c) 2001-2008 Jamie Zawinski <jwz@jwz.org>
+/* gltext, Copyright (c) 2001-2014 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
@@ -30,6 +30,7 @@
 #include "xlockmore.h"
 #include "colors.h"
 #include "tube.h"
+#include "sphere.h"
 #include "rotator.h"
 #include "gltrackball.h"
 #include "textclient.h"
@@ -197,11 +198,11 @@ parse_text (ModeInfo *mi)
       while (p < buf + sizeof(buf) - 1 &&
              lines < max_lines)
         {
-          char c = textclient_getc (tp->tc);
+          int c = textclient_getc (tp->tc);
           if (c == '\n')
             lines++;
           if (c > 0)
-            *p++ = c;
+            *p++ = (char) c;
           else
             break;
         }
@@ -233,6 +234,10 @@ parse_text (ModeInfo *mi)
 #  if defined(_AIX)
           sprintf(tp->text, "%s\n%s %s.%s",
                   uts.nodename, uts.sysname, uts.version, uts.release);
+#  elif defined(USE_IPHONE)
+          /* "My iPhone\n iPhone4,1\n Darwin 11.0.0" */
+          sprintf(tp->text, "%s\n%s\n%s %s",
+                  uts.nodename, uts.machine, uts.sysname, uts.release);
 #  elif defined(__APPLE__)  /* MacOS X + XDarwin */
           {
             const char *file = 
@@ -301,39 +306,10 @@ text_handle_event (ModeInfo *mi, XEvent *event)
 {
   text_configuration *tp = &tps[MI_SCREEN(mi)];
 
-  if (event->xany.type == ButtonPress &&
-      event->xbutton.button == Button1)
-    {
-      tp->button_down_p = True;
-      gltrackball_start (tp->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)
-    {
-      tp->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 (tp->trackball, event->xbutton.button, 10,
-                              !!event->xbutton.state);
-      return True;
-    }
-  else if (event->xany.type == MotionNotify &&
-           tp->button_down_p)
-    {
-      gltrackball_track (tp->trackball,
-                         event->xmotion.x, event->xmotion.y,
-                         MI_WIDTH (mi), MI_HEIGHT (mi));
-      return True;
-    }
+  if (gltrackball_event_handler (event, tp->trackball,
+                                 MI_WIDTH (mi), MI_HEIGHT (mi),
+                                 &tp->button_down_p))
+    return True;
 
   return False;
 }
@@ -393,7 +369,7 @@ init_text (ModeInfo *mi)
     tp->rot2 = (face_front_p
                 ? make_rotator (0, 0, 0, 0, tilt_speed, True)
                 : 0);
-    tp->trackball = gltrackball_init ();
+    tp->trackball = gltrackball_init (False);
   }
 
   tp->ncolors = 255;
@@ -444,14 +420,26 @@ fill_character (GLUTstrokeFont font, int c, Bool wire, int *polysP)
 # else
             int smooth = False;
 # endif
+
             if (j != stroke->num_coords)
               *polysP += tube (lx,       ly,       0,
                                coord->x, coord->y, 0,
                                tube_width,
                                tube_width * 0.15,
-                               TUBE_FACES, smooth, True, wire);
+                               TUBE_FACES, smooth, False, wire);
             lx = coord->x;
             ly = coord->y;
+
+            /* Put a sphere at the endpoint of every line segment.  Wasteful
+               on curves like "0" but necessary on corners like "4". */
+            if (! wire)
+              {
+                glPushMatrix();
+                glTranslatef (lx, ly, 0);
+                glScalef (tube_width, tube_width, tube_width);
+                *polysP += unit_sphere (TUBE_FACES, TUBE_FACES, wire);
+                glPopMatrix();
+              }
           }
       }
       return (int) (ch->right + tube_width);
@@ -586,6 +574,7 @@ draw_text (ModeInfo *mi)
 
   glPushMatrix ();
   glScalef(1.1, 1.1, 1.1);
+  glRotatef(current_device_rotation(), 0, 0, 1);
 
   {
     double x, y, z;
@@ -595,7 +584,6 @@ draw_text (ModeInfo *mi)
                  (z - 0.5) * 8);
 
     gltrackball_rotate (tp->trackball);
-    glRotatef(current_device_rotation(), 0, 0, 1);
 
     if (face_front_p)
       {