X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=OSX%2FXScreenSaverView.m;h=932e7db776b680ca156010b03f4f4e295427f55b;hp=2baf2c69f9e3575cc026671e2d44f2b5e8e5147d;hb=c1b9b55ad8d59dc05ef55e316aebf5863e7dfa56;hpb=de460e831dc8578acfa8b72251ab9346c99c1f96 diff --git a/OSX/XScreenSaverView.m b/OSX/XScreenSaverView.m index 2baf2c69..932e7db7 100644 --- a/OSX/XScreenSaverView.m +++ b/OSX/XScreenSaverView.m @@ -126,9 +126,12 @@ add_default_options (const XrmOptionDescRec *opts, { "-choose-random-images", ".chooseRandomImages",XrmoptionNoArg, "True" }, { "-no-choose-random-images",".chooseRandomImages",XrmoptionNoArg, "False"}, { "-image-directory", ".imageDirectory", XrmoptionSepArg, 0 }, + { "-fps", ".doFPS", XrmoptionNoArg, "True" }, + { "-no-fps", ".doFPS", XrmoptionNoArg, "False"}, { 0, 0, 0, 0 } }; static const char *default_defaults [] = { + ".doFPS: False", ".textMode: date", // ".textLiteral: ", // ".textFile: ", @@ -262,6 +265,13 @@ add_default_options (const XrmOptionDescRec *opts, [self lockFocus]; // in case something tries to draw from here [self prepareContext]; + + /* I considered just not even calling the free callback at all... + But webcollage-cocoa needs it, to kill the inferior webcollage + processes (since the screen saver framework never generates a + SIGPIPE for them...) Instead, I turned off the free call in + xlockmore.c, which is where all of the bogus calls are anyway. + */ xsft->free_cb (xdpy, xwindow, xdata); [self unlockFocus]; @@ -286,6 +296,15 @@ add_default_options (const XrmOptionDescRec *opts, { } + +static void +screenhack_do_fps (Display *dpy, Window w, fps_state *fpst, void *closure) +{ + fps_compute (fpst, 0); + fps_draw (fpst); +} + + - (void) animateOneFrame { if (!initted_p) { @@ -333,6 +352,11 @@ add_default_options (const XrmOptionDescRec *opts, (void *(*) (Display *, Window, void *)) xsft->init_cb; xdata = init_cb (xdpy, xwindow, xsft->setup_arg); + + if (get_boolean_resource (xdpy, "doFPS", "DoFPS")) { + fpst = fps_init (xdpy, xwindow); + if (! xsft->fps_cb) xsft->fps_cb = screenhack_do_fps; + } } /* I don't understand why we have to do this *every frame*, but we do, @@ -341,6 +365,18 @@ add_default_options (const XrmOptionDescRec *opts, if (![self isPreview]) [NSCursor setHiddenUntilMouseMoves:YES]; + + if (fpst) + { + /* This is just a guess, but the -fps code wants to know how long + we were sleeping between frames. + */ + unsigned long usecs = 1000000 * [self animationTimeInterval]; + usecs -= 200; // caller apparently sleeps for slightly less sometimes... + fps_slept (fpst, usecs); + } + + /* It turns out that [ScreenSaverView setAnimationTimeInterval] does nothing. This is bad, because some of the screen hacks want to delay for long periods (like 5 seconds or a minute!) between frames, and running them @@ -386,6 +422,7 @@ add_default_options (const XrmOptionDescRec *opts, // NSDisableScreenUpdates(); unsigned long delay = xsft->draw_cb (xdpy, xwindow, xdata); + if (fpst) xsft->fps_cb (xdpy, xwindow, fpst, xdata); XSync (xdpy, 0); NSEnableScreenUpdates(); @@ -517,7 +554,7 @@ add_default_options (const XrmOptionDescRec *opts, case KeyRelease: { NSString *nss = [e characters]; - const char *s = [nss cStringUsingEncoding:NSUTF8StringEncoding]; + const char *s = [nss cStringUsingEncoding:NSISOLatin1StringEncoding]; xe.xkey.keycode = (s && *s ? *s : 0); xe.xkey.state = state; break;