X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fxlockmore.c;h=28828beb1e25439958dcd026bb421fb0f645630c;hb=a94197e76a5dea5cb60542840809d6c20d0abbf3;hp=a1e71aa2e1f449809f7a42fdee5a690b0607d747;hpb=6bb727f03bff0389fbb1349d7df4c9d8d7532959;p=xscreensaver diff --git a/hacks/xlockmore.c b/hacks/xlockmore.c index a1e71aa2..28828beb 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 Jamie Zawinski + * xscreensaver, Copyright (c) 1997, 1998, 2001 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 @@ -11,7 +11,7 @@ * * This file, along with xlockmore.h, make it possible to compile an xlockmore * module into a standalone program, and thus use it with xscreensaver. - * By Jamie Zawinski on 10-May-97; based on the ideas + * By Jamie Zawinski on 10-May-97; based on the ideas * in the older xlock.h by Charles Hannum . (I had * to redo it, since xlockmore has diverged so far from xlock...) */ @@ -19,11 +19,15 @@ #include #include #include +#include +#include #include "screenhack.h" #include "xlockmoreI.h" #define countof(x) (sizeof((x))/sizeof(*(x))) +#define MAX_COLORS (1L<<13) + extern ModeSpecOpt xlockmore_opts[]; extern const char *app_defaults; @@ -61,7 +65,8 @@ pre_merge_options (void) /* Add extra args, if they're mentioned in the defaults... */ { char *args[] = { "-count", "-cycles", "-delay", "-ncolors", - "-size", "-wireframe", "-use3d" }; + "-size", "-wireframe", "-use3d", "-useSHM", + "-showFPS" }; for (j = 0; j < countof(args); j++) if (strstr(app_defaults, args[j]+1)) { @@ -75,7 +80,7 @@ pre_merge_options (void) new->value = "True"; new = &options[i++]; new->option = "-no-wireframe"; - new->specifier = options[i-1].specifier; + new->specifier = options[i-2].specifier; new->argKind = XrmoptionNoArg; new->value = "False"; } @@ -86,7 +91,29 @@ pre_merge_options (void) new->value = "True"; new = &options[i++]; new->option = "-no-3d"; - new->specifier = options[i-1].specifier; + new->specifier = options[i-2].specifier; + new->argKind = XrmoptionNoArg; + new->value = "False"; + } + else if (!strcmp(new->option, "-useSHM")) + { + new->option = "-shm"; + new->argKind = XrmoptionNoArg; + new->value = "True"; + new = &options[i++]; + new->option = "-no-shm"; + new->specifier = options[i-2].specifier; + new->argKind = XrmoptionNoArg; + new->value = "False"; + } + else if (!strcmp(new->option, "-showFPS")) + { + new->option = "-fps"; + new->argKind = XrmoptionNoArg; + new->value = "True"; + new = &options[i++]; + new->option = "-no-fps"; + new->specifier = options[i-2].specifier; new->argKind = XrmoptionNoArg; new->value = "False"; } @@ -129,8 +156,11 @@ pre_merge_options (void) for (j = 0; j < xlockmore_opts->numvarsdesc; j++) { const char *def = xlockmore_opts->vars[j].def; - if (!def) def = "False"; - if (def == ((char*) 1)) def = "True"; + + if (!def) abort(); + if (!*def) abort(); + if (strlen(def) > 1000) abort(); + s = (char *) malloc (strlen (xlockmore_opts->vars[j].name) + strlen (def) + 10); strcpy (s, "*"); @@ -181,6 +211,26 @@ xlockmore_read_resources (void) } +static void +xlockmore_handle_events (ModeInfo *mi, + void (*reshape) (ModeInfo *, int, int)) +{ + while (XPending (mi->dpy)) + { + XEvent event; + XNextEvent (mi->dpy, &event); + if (reshape && event.xany.type == ConfigureNotify) + { + XGetWindowAttributes (mi->dpy, mi->window, &mi->xgwa); + reshape (mi, mi->xgwa.width, mi->xgwa.height); + } + else + { + screenhack_handle_event (mi->dpy, &event); + } + } +} + void xlockmore_screenhack (Display *dpy, Window window, @@ -190,6 +240,7 @@ xlockmore_screenhack (Display *dpy, Window window, Bool want_bright_colors, void (*hack_init) (ModeInfo *), void (*hack_draw) (ModeInfo *), + void (*hack_reshape) (ModeInfo *, int, int), void (*hack_free) (ModeInfo *)) { ModeInfo mi; @@ -235,8 +286,8 @@ xlockmore_screenhack (Display *dpy, Window window, mi.npixels = get_integer_resource ("ncolors", "Integer"); if (mi.npixels <= 0) mi.npixels = 64; - else if (mi.npixels > 256) - mi.npixels = 256; + else if (mi.npixels > MAX_COLORS) + mi.npixels = MAX_COLORS; mi.colors = (XColor *) calloc (mi.npixels, sizeof (*mi.colors)); @@ -280,29 +331,6 @@ xlockmore_screenhack (Display *dpy, Window window, mi.batchcount = get_integer_resource ("count", "Int"); mi.size = get_integer_resource ("size", "Int"); -#if 0 - decay = get_boolean_resource ("decay", "Boolean"); - if (decay) mi.fullrandom = False; - - trail = get_boolean_resource ("trail", "Boolean"); - if (trail) mi.fullrandom = False; - - grow = get_boolean_resource ("grow", "Boolean"); - if (grow) mi.fullrandom = False; - - liss = get_boolean_resource ("liss", "Boolean"); - if (liss) mi.fullrandom = False; - - ammann = get_boolean_resource ("ammann", "Boolean"); - if (ammann) mi.fullrandom = False; - - jong = get_boolean_resource ("jong", "Boolean"); - if (jong) mi.fullrandom = False; - - sine = get_boolean_resource ("sine", "Boolean"); - if (sine) mi.fullrandom = False; -#endif - mi.threed = get_boolean_resource ("use3d", "Boolean"); mi.threed_delta = get_float_resource ("delta3d", "Boolean"); mi.threed_right_color = get_pixel_resource ("right3d", "Color", dpy, @@ -316,7 +344,10 @@ xlockmore_screenhack (Display *dpy, Window window, mi.wireframe_p = get_boolean_resource ("wireframe", "Boolean"); mi.root_p = (window == RootWindowOfScreen (mi.xgwa.screen)); - + mi.fps_p = get_boolean_resource ("showFPS", "Boolean"); +#ifdef HAVE_XSHM_EXTENSION + mi.use_shm = get_boolean_resource ("useSHM", "Boolean"); +#endif /* !HAVE_XSHM_EXTENSION */ if (mi.pause < 0) mi.pause = 0; @@ -335,6 +366,7 @@ xlockmore_screenhack (Display *dpy, Window window, do { hack_draw (&mi); XSync(dpy, False); + xlockmore_handle_events (&mi, hack_reshape); if (mi.pause) usleep(mi.pause); mi.pause = orig_pause;