From http://www.jwz.org/xscreensaver/xscreensaver-5.33.tar.gz
[xscreensaver] / hacks / glx / fps-gl.c
index 46757708c937c6bb3698b543b3cdb30553a6dd83..6020b257ea59e3ca3cec8c2e02264a27fdc6da75 100644 (file)
@@ -1,4 +1,4 @@
-/* fps, Copyright (c) 2001-2014 Jamie Zawinski <jwz@jwz.org>
+/* fps, Copyright (c) 2001-2015 Jamie Zawinski <jwz@jwz.org>
  * Draw a frames-per-second display (Xlib and OpenGL).
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
@@ -38,6 +38,7 @@ extern void check_gl_error (const char *type);
 typedef struct {
   texture_font_data *texfont;
   int line_height;
+  Bool top_p;
 } gl_fps_data;
 
 
@@ -45,8 +46,11 @@ static void
 xlockmore_gl_fps_init (fps_state *st)
 {
   gl_fps_data *data = (gl_fps_data *) calloc (1, sizeof(*data));
+  int ascent, descent;
+  data->top_p = get_boolean_resource (st->dpy, "fpsTop", "FPSTop");
   data->texfont = load_texture_font (st->dpy, "fpsFont");
-  texture_string_width (data->texfont, "M", &data->line_height);
+  texture_string_metrics (data->texfont, "M", 0, &ascent, &descent);
+  data->line_height = ascent + descent;
   st->gl_fps_data = data;
 }
 
@@ -93,6 +97,7 @@ xlockmore_gl_draw_fps (ModeInfo *mi)
       glColor3f (1, 1, 1);
       print_texture_label (st->dpy, data->texfont,
                            xgwa.width, xgwa.height,
-                           2, st->string);
+                           (data->top_p ? 1 : 2),
+                           st->string);
     }
 }