From http://www.jwz.org/xscreensaver/xscreensaver-5.30.tar.gz
[xscreensaver] / hacks / glx / glslideshow.c
index be77dc1fef0a66e6af3960e2ff55beadeb1d9adf..bf5f87d22428cbb761a29bf450b899404af1391c 100644 (file)
@@ -1,4 +1,4 @@
-/* glslideshow, Copyright (c) 2003-2011 Jamie Zawinski <jwz@jwz.org>
+/* glslideshow, Copyright (c) 2003-2014 Jamie Zawinski <jwz@jwz.org>
  * Loads a sequence of images and smoothly pans around them; crossfades
  * when loading new images.
  *
@@ -160,8 +160,7 @@ typedef struct {
   Bool checked_fps_p;          /* Whether we have checked for a low
                                    frame rate. */
 
-  XFontStruct *xfont;          /* for printing image file names */
-  GLuint font_dlist;
+  texture_font_data *font_data;        /* for printing image file names */
 
   int sprite_id, image_id;      /* debugging id counters */
 
@@ -358,17 +357,17 @@ image_loaded_cb (const char *filename, XRectangle *geom,
       img->geom.height *= scale;
     }
 
-# if 0 /* xscreensaver-getimage returns paths relative to the image directory
-          now, so leave the sub-directory part in.
-        */
-  if (img->title)  /* strip filename to part between last "/" and last ".". */
+  /* xscreensaver-getimage returns paths relative to the image directory
+     now, so leave the sub-directory part in.  Unless it's an absolute path.
+  */
+  if (img->title && img->title[0] == '/')
     {
+      /* strip filename to part between last "/" and last ".". */
       char *s = strrchr (img->title, '/');
       if (s) strcpy (img->title, s+1);
       s = strrchr (img->title, '.');
       if (s) *s = 0;
     }
-# endif /* 0 */
 
   if (debug_p)
     fprintf (stderr, "%s: loaded   img %2d: \"%s\"\n",
@@ -812,12 +811,12 @@ draw_sprite (ModeInfo *mi, sprite *sp)
         int x = 10;
         int y = mi->xgwa.height - 10;
         glColor4f (0, 0, 0, sp->opacity);   /* cheap-assed dropshadow */
-        print_gl_string (mi->dpy, ss->xfont, ss->font_dlist,
+        print_gl_string (mi->dpy, ss->font_data,
                          mi->xgwa.width, mi->xgwa.height, x, y,
                          img->title, False);
         x++; y++;
         glColor4f (1, 1, 1, sp->opacity);
-        print_gl_string (mi->dpy, ss->xfont, ss->font_dlist,
+        print_gl_string (mi->dpy, ss->font_data,
                          mi->xgwa.width, mi->xgwa.height, x, y,
                          img->title, False);
       }
@@ -873,6 +872,20 @@ draw_sprites (ModeInfo *mi)
   glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
   glPushMatrix();
+
+  {
+    GLfloat rot = current_device_rotation();
+    glTranslatef (0.5, 0.5, 0);
+    glRotatef(rot, 0, 0, 1);
+    if ((rot >  45 && rot <  135) ||
+        (rot < -45 && rot > -135))
+      {
+        GLfloat s = MI_WIDTH(mi) / (GLfloat) MI_HEIGHT(mi);
+        glScalef (s, 1/s, 1);
+      }
+    glTranslatef (-0.5, -0.5, 0);
+  }
+
   for (i = 0; i < ss->nsprites; i++)
     draw_sprite (mi, ss->sprites[i]);
   glPopMatrix();
@@ -929,24 +942,7 @@ slideshow_handle_event (ModeInfo *mi, XEvent *event)
 {
   slideshow_state *ss = &sss[MI_SCREEN(mi)];
 
-  if (event->xany.type == ButtonPress &&
-      event->xbutton.button == Button1)
-    {
-      ss->change_now_p = True;
-      return True;
-    }
-  else if (event->xany.type == KeyPress)
-    {
-      KeySym keysym;
-      char c = 0;
-      XLookupString (&event->xkey, &c, 1, &keysym, 0);
-      if (c == ' ' || c == '\r' || c == '\n' || c == '\t')
-        {
-          ss->change_now_p = True;
-          return True;
-        }
-    }
-  else if (event->xany.type == Expose ||
+  if (event->xany.type == Expose ||
            event->xany.type == GraphicsExpose ||
            event->xany.type == VisibilityNotify)
     {
@@ -955,6 +951,11 @@ slideshow_handle_event (ModeInfo *mi, XEvent *event)
         fprintf (stderr, "%s: exposure\n", blurb());
       return False;
     }
+  else if (screenhack_event_helper (MI_DISPLAY(mi), MI_WINDOW(mi), event))
+    {
+      ss->change_now_p = True;
+      return True;
+    }
 
   return False;
 }
@@ -1120,7 +1121,7 @@ init_slideshow (ModeInfo *mi)
 
   if (debug_p) glLineWidth (3);
 
-  load_font (mi->dpy, "titleFont", &ss->xfont, &ss->font_dlist);
+  ss->font_data = load_texture_font (mi->dpy, "titleFont");
 
   if (debug_p)
     hack_resources();
@@ -1214,7 +1215,6 @@ draw_slideshow (ModeInfo *mi)
 
   draw_sprites (mi);
 
-  ss->fps = fps_compute (mi->fpst, 0);
   if (mi->fps_p) do_fps (mi);
 
   glFinish();