X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fxlockmore.c;h=d5b71f9bb4f956b595cd1daf50b3a6d324117bd4;hb=6afd6db0ae9396cd7ff897ade597cd5483f49b0e;hp=34cffeb1c60482813fbcd864def957a8cbe5c51c;hpb=c1b9b55ad8d59dc05ef55e316aebf5863e7dfa56;p=xscreensaver diff --git a/hacks/xlockmore.c b/hacks/xlockmore.c index 34cffeb1..d5b71f9b 100644 --- a/hacks/xlockmore.c +++ b/hacks/xlockmore.c @@ -1,5 +1,5 @@ /* xlockmore.c --- xscreensaver compatibility layer for xlockmore modules. - * xscreensaver, Copyright (c) 1997-2008 Jamie Zawinski + * xscreensaver, Copyright (c) 1997-2014 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -282,7 +282,6 @@ xlockmore_init (Display *dpy, Window window, XGCValues gcv; XColor color; int i; - int orig_pause; Bool root_p; if (! xlmft) @@ -295,26 +294,28 @@ xlockmore_init (Display *dpy, Window window, #ifdef HAVE_COCOA +# if 0 /* In Cocoa-based xscreensaver, all hacks run in the same address space, - so each one needs to get its own screen number. We just use a global - counter for that, instead of actually trying to figure out which - monitor each window is on. Also, the embedded "preview" view counts - as a screen as well. - - Note that the screen number will increase each time the saver is - restarted (e.g., each time preferences are changed!) So we just - keep pushing the num_screens number up as needed, and assume that - no more than 10 simultanious copies will be running at once... + so each one needs to get its own screen number. Believe what jwxyz + says about screen counts and numbers. */ - { - static int screen_tick = 0; - mi->num_screens = 10; - mi->screen_number = screen_tick++; - if (screen_tick >= mi->num_screens) - mi->num_screens += 10; - } - + mi->num_screens = ScreenCount (dpy); + mi->screen_number = XScreenNumberOfScreen (mi->xgwa.screen); +# else + /* No, that doesn't work. + The xlockmore docs/HACKERS.GUIDE says that xlock modes are supposed to + support repeated calls to init_*() for the same screen in the same + session, but in practice, a number of them blow up if you do that. + So instead we're stuck with a world where on OSX/iOS, we have to + increment the screen number every time the hack is run. Arrgh. + */ + mi->num_screens = 40; + mi->screen_number = xlmft->screen_count; + if (mi->screen_number >= mi->num_screens) abort(); + xlmft->screen_count++; +# endif root_p = True; + #else /* !HAVE_COCOA -- real Xlib */ /* In Xlib-based xscreensaver, each hack runs in its own address space, @@ -383,18 +384,21 @@ xlockmore_init (Display *dpy, Window window, switch (mi->xlmft->desired_color_scheme) { case color_scheme_uniform: - make_uniform_colormap (dpy, mi->xgwa.visual, mi->xgwa.colormap, + make_uniform_colormap (mi->xgwa.screen, mi->xgwa.visual, + mi->xgwa.colormap, mi->colors, &mi->npixels, True, &mi->writable_p, True); break; case color_scheme_smooth: - make_smooth_colormap (dpy, mi->xgwa.visual, mi->xgwa.colormap, + make_smooth_colormap (mi->xgwa.screen, mi->xgwa.visual, + mi->xgwa.colormap, mi->colors, &mi->npixels, True, &mi->writable_p, True); break; case color_scheme_bright: case color_scheme_default: - make_random_colormap (dpy, mi->xgwa.visual, mi->xgwa.colormap, + make_random_colormap (mi->xgwa.screen, mi->xgwa.visual, + mi->xgwa.colormap, mi->colors, &mi->npixels, (mi->xlmft->desired_color_scheme == color_scheme_bright), @@ -444,12 +448,12 @@ xlockmore_init (Display *dpy, Window window, mi->use_shm = get_boolean_resource (dpy, "useSHM", "Boolean"); #endif /* !HAVE_XSHM_EXTENSION */ mi->fps_p = get_boolean_resource (dpy, "doFPS", "DoFPS"); + mi->recursion_depth = -1; /* see fps.c */ if (mi->pause < 0) mi->pause = 0; else if (mi->pause > 100000000) mi->pause = 100000000; - orig_pause = mi->pause; /* If this hack uses fonts (meaning, mentioned "font" in DEFAULTS) then load it. */ @@ -525,6 +529,15 @@ xlockmore_event (Display *dpy, Window window, void *closure, XEvent *event) return False; } +void +xlockmore_do_fps (Display *dpy, Window w, fps_state *fpst, void *closure) +{ + ModeInfo *mi = (ModeInfo *) closure; + fps_compute (fpst, 0, mi ? mi->recursion_depth : -1); + fps_draw (fpst); +} + + static void xlockmore_free (Display *dpy, Window window, void *closure) {