X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fxlockmore.c;h=8d05b29ef11eb4bd3182ba49464bf8fc5442920e;hb=447db08c956099b3b183886729108bf5b364c4b8;hp=12d31ffef519a10e73872545b0fe98311809b0e4;hpb=13dbc569cdc6e29019722c0ef9b932a925efbcad;p=xscreensaver diff --git a/hacks/xlockmore.c b/hacks/xlockmore.c index 12d31ffe..8d05b29e 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, 1998, 2001, 2002 + * xscreensaver, Copyright (c) 1997, 1998, 2001, 2002, 2004 * Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its @@ -24,11 +24,13 @@ #include #include "screenhack.h" #include "xlockmoreI.h" +#include #define countof(x) (sizeof((x))/sizeof(*(x))) #define MAX_COLORS (1L<<13) +extern XtAppContext app; extern ModeSpecOpt xlockmore_opts[]; extern const char *app_defaults; @@ -66,7 +68,7 @@ pre_merge_options (void) /* Add extra args, if they're mentioned in the defaults... */ { char *args[] = { "-count", "-cycles", "-delay", "-ncolors", - "-size", "-wireframe", "-use3d", "-useSHM", + "-size", "-font", "-wireframe", "-use3d", "-useSHM", "-showFPS" }; for (j = 0; j < countof(args); j++) if (strstr(app_defaults, args[j]+1)) @@ -169,6 +171,35 @@ pre_merge_options (void) strcat (s, ": "); strcat (s, def); defaults [i++] = s; + + /* Go through the list of resources and print a warning if there + are any duplicates. + */ + { + char *onew = strdup (xlockmore_opts->vars[j].name); + const char *new = onew; + char *s; + int k; + if ((s = strrchr (new, '.'))) new = s+1; + if ((s = strrchr (new, '*'))) new = s+1; + for (k = 0; k < i-1; k++) + { + char *oold = strdup (defaults[k]); + const char *old = oold; + if ((s = strchr (oold, ':'))) *s = 0; + if ((s = strrchr (old, '.'))) old = s+1; + if ((s = strrchr (old, '*'))) old = s+1; + if (!strcasecmp (old, new)) + { + fprintf (stderr, + "%s: duplicate resource \"%s\": " + "set in both DEFAULTS and vars[]\n", + progname, old); + } + free (oold); + } + free (onew); + } } defaults [i] = 0; @@ -217,6 +248,9 @@ xlockmore_handle_events (ModeInfo *mi, void (*reshape) (ModeInfo *, int, int), Bool (*hook) (ModeInfo *, XEvent *)) { + if (XtAppPending (app) & (XtIMTimer|XtIMAlternateInput)) + XtAppProcessEvent (app, XtIMTimer|XtIMAlternateInput); + while (XPending (mi->dpy)) { XEvent event; @@ -329,7 +363,6 @@ xlockmore_screenhack (Display *dpy, Window window, goto MONO; else { - int i; mi.pixels = (unsigned long *) calloc (mi.npixels, sizeof (*mi.pixels)); for (i = 0; i < mi.npixels; i++) @@ -373,6 +406,32 @@ xlockmore_screenhack (Display *dpy, Window window, mi.pause = 100000000; orig_pause = mi.pause; + /* If this hack uses fonts (meaning, mentioned "font" in DEFAULTS) + then load it. */ + { + char *name = get_string_resource ("font", "Font"); + if (name) + { + XFontStruct *f = XLoadQueryFont (dpy, name); + const char *def1 = "-*-times-bold-r-normal-*-180-*"; + const char *def2 = "fixed"; + if (!f) + { + fprintf (stderr, "%s: font %s does not exist, using %s\n", + progname, name, def1); + f = XLoadQueryFont (dpy, def1); + } + if (!f) + { + fprintf (stderr, "%s: font %s does not exist, using %s\n", + progname, def1, def2); + f = XLoadQueryFont (dpy, def2); + } + if (f) XSetFont (dpy, mi.gc, f->fid); + if (f) XFreeFont (dpy, f); + } + } + xlockmore_read_resources (); XClearWindow (dpy, window);