X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=OSX%2FXScreenSaverView.m;h=932e7db776b680ca156010b03f4f4e295427f55b;hb=c1b9b55ad8d59dc05ef55e316aebf5863e7dfa56;hp=6caf2e8cbf5a45e0beca364f004814de154822e9;hpb=488f2fa8fbdbc77e91a70da2962d73af49e6cace;p=xscreensaver diff --git a/OSX/XScreenSaverView.m b/OSX/XScreenSaverView.m index 6caf2e8c..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 @@ -384,10 +420,12 @@ add_default_options (const XrmOptionDescRec *opts, // And finally: // + NSDisableScreenUpdates(); unsigned long delay = xsft->draw_cb (xdpy, xwindow, xdata); - + if (fpst) xsft->fps_cb (xdpy, xwindow, fpst, xdata); XSync (xdpy, 0); - + NSEnableScreenUpdates(); + gettimeofday (&tv, 0); now = tv.tv_sec + (tv.tv_usec / 1000000.0); next_frame_time = now + (delay / 1000000.0); @@ -499,7 +537,11 @@ add_default_options (const XrmOptionDescRec *opts, xe.xbutton.y = y; xe.xbutton.state = state; if ([e type] == NSScrollWheel) - xe.xbutton.button = ([e deltaY] > 0 ? Button4 : Button5); + xe.xbutton.button = ([e deltaY] > 0 ? Button4 : + [e deltaY] < 0 ? Button5 : + [e deltaX] > 0 ? Button6 : + [e deltaX] < 0 ? Button7 : + 0); else xe.xbutton.button = [e buttonNumber] + 1; break; @@ -512,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;