X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Ffps.c;h=a24f62315f98879d8d7b792290be78c830446bd6;hb=78add6e627ee5f10e1fa6f3852602ea5066eee5a;hp=44171730461de142a3d80c6cd9528bc075f3b1c7;hpb=8afc01a67be4fbf3f1cc0fce9adf01b5289a21c6;p=xscreensaver diff --git a/hacks/fps.c b/hacks/fps.c index 44171730..a24f6231 100644 --- a/hacks/fps.c +++ b/hacks/fps.c @@ -1,4 +1,4 @@ -/* fps, Copyright (c) 2001-2011 Jamie Zawinski +/* fps, Copyright (c) 2001-2018 Jamie Zawinski * Draw a frames-per-second display (Xlib and OpenGL). * * Permission to use, copy, modify, distribute, and sell this software and its @@ -14,6 +14,7 @@ # include "config.h" #endif /* HAVE_CONFIG_H */ +#include #include "screenhackI.h" #include "fpsI.h" @@ -23,10 +24,16 @@ fps_init (Display *dpy, Window window) fps_state *st; const char *font; XFontStruct *f; + Bool top_p; + XWindowAttributes xgwa; if (! get_boolean_resource (dpy, "doFPS", "DoFPS")) return 0; + if (!strcasecmp (progname, "BSOD")) return 0; /* Never worked right */ + + top_p = get_boolean_resource (dpy, "fpsTop", "FPSTop"); + st = (fps_state *) calloc (1, sizeof(*st)); st->dpy = dpy; @@ -35,12 +42,12 @@ fps_init (Display *dpy, Window window) font = get_string_resource (dpy, "fpsFont", "Font"); - if (!font) font = "-*-courier-bold-r-normal-*-180-*"; - f = XLoadQueryFont (dpy, font); - if (!f) f = XLoadQueryFont (dpy, "fixed"); + if (!font) + font = "-*-courier-bold-r-normal-*-*-180-*-*-*-*-*-*"; /* also texfont.c */ + f = load_font_retry (dpy, font); + if (!f) abort(); { - XWindowAttributes xgwa; XGCValues gcv; XGetWindowAttributes (dpy, window, &xgwa); gcv.font = f->fid; @@ -55,9 +62,19 @@ fps_init (Display *dpy, Window window) st->font = f; st->x = 10; st->y = 10; - if (get_boolean_resource (dpy, "fpsTop", "FPSTop")) - /* don't leave a blank line in GL top-fps. */ - st->y = - (/*st->font->ascent +*/ st->font->descent + 10); + if (top_p) + st->y = - (st->font->ascent + st->font->descent + 10); + +# ifdef USE_IPHONE + /* Don't hide the FPS display under the iPhone X bezel. + #### This is the worst of all possible ways to do this! But how else? + */ + if (xgwa.width == 2436 || xgwa.height == 2436) + { + st->x += 48; + st->y += 48 * (top_p ? -1 : 1); + } +# endif strcpy (st->string, "FPS: ... ");