X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=driver%2Fxscreensaver.c;h=f3f43a772747a098742b86cb6cf9ec0659126aae;hb=0bd2eabab3e404c6769fe8f59b639275e960c415;hp=d820d0aba2549c07912b3f14848ebdf4a19ea176;hpb=6bb727f03bff0389fbb1349d7df4c9d8d7532959;p=xscreensaver diff --git a/driver/xscreensaver.c b/driver/xscreensaver.c index d820d0ab..f3f43a77 100644 --- a/driver/xscreensaver.c +++ b/driver/xscreensaver.c @@ -108,7 +108,7 @@ * window exposed. * - If you run your debugger under XEmacs, try M-ESC (x-grab-keyboard) * to keep your emacs window alive even when xscreensaver has grabbed. - * - Go read the code related to -DDEBUG. + * - Go read the code related to `debug_p'. * - You probably can't set breakpoints in functions that are called on * the other side of a call to fork() -- if your clients are dying * with signal 5, Trace/BPT Trap, you're losing in this way. @@ -158,7 +158,6 @@ char *progclass = 0; XrmDatabase db = 0; -static Atom XA_SCREENSAVER; static Atom XA_ACTIVATE, XA_DEACTIVATE, XA_CYCLE, XA_NEXT, XA_PREV; static Atom XA_EXIT, XA_RESTART, XA_DEMO, XA_LOCK; @@ -166,10 +165,10 @@ static Atom XA_EXIT, XA_RESTART, XA_DEMO, XA_LOCK; static XrmOptionDescRec options [] = { { "-timeout", ".timeout", XrmoptionSepArg, 0 }, { "-cycle", ".cycle", XrmoptionSepArg, 0 }, - { "-idelay", ".initialDelay", XrmoptionSepArg, 0 }, - { "-nice", ".nice", XrmoptionSepArg, 0 }, - { "-visual", ".visualID", XrmoptionSepArg, 0 }, + { "-lock-mode", ".lock", XrmoptionNoArg, "on" }, + { "-no-lock-mode", ".lock", XrmoptionNoArg, "off" }, { "-lock-timeout", ".lockTimeout", XrmoptionSepArg, 0 }, + { "-visual", ".visualID", XrmoptionSepArg, 0 }, { "-install", ".installColormap", XrmoptionNoArg, "on" }, { "-no-install", ".installColormap", XrmoptionNoArg, "off" }, { "-verbose", ".verbose", XrmoptionNoArg, "on" }, @@ -180,8 +179,8 @@ static XrmOptionDescRec options [] = { { "-no-mit-extension", ".mitSaverExtension",XrmoptionNoArg, "off" }, { "-sgi-extension", ".sgiSaverExtension",XrmoptionNoArg, "on" }, { "-no-sgi-extension", ".sgiSaverExtension",XrmoptionNoArg, "off" }, - { "-lock", ".lock", XrmoptionNoArg, "on" }, - { "-no-lock", ".lock", XrmoptionNoArg, "off" } + { "-idelay", ".initialDelay", XrmoptionSepArg, 0 }, + { "-nice", ".nice", XrmoptionSepArg, 0 } }; static char *defaults[] = { @@ -198,29 +197,29 @@ The standard Xt command-line options are accepted; other options include:\n\ \n\ -timeout When the screensaver should activate.\n\ -cycle How long to let each hack run.\n\ - -idelay How long to sleep before startup.\n\ + -lock-mode Require a password before deactivating.\n\ + -no-lock-mode Don't.\n\ + -lock-timeout Grace period before locking; default 0.\n\ -visual Which X visual to run on.\n\ - -demo Enter interactive demo mode on startup.\n\ -install Install a private colormap.\n\ -no-install Don't.\n\ -verbose Be loud.\n\ -silent Don't.\n\ - -xidle-extension Use the R5 XIdle server extension.\n\ - -no-xidle-extension Don't.\n\ -mit-extension Use the R6 MIT_SCREEN_SAVER server extension.\n\ -no-mit-extension Don't.\n\ -sgi-extension Use the SGI SCREEN-SAVER server extension.\n\ -no-sgi-extension Don't.\n\ - -lock Require a password before deactivating.\n\ - -no-lock Don't.\n\ - -lock-timeout Grace period before locking; default 0.\n\ + -xidle-extension Use the R5 XIdle server extension.\n\ + -no-xidle-extension Don't.\n\ -help This message.\n\ \n\ -Use the `xscreensaver-command' program to control a running screensaver.\n\ +The `xscreensaver' program should be left running in the background.\n\ +Use the `xscreensaver-command' program to manipulate a running xscreensaver.\n\ \n\ -The *programs resource controls which graphics demos will be launched by the\n\ -screensaver. See the man page for more details. For updates, check\n\ -http://people.netscape.com/jwz/xscreensaver/\n\n", +The `*programs' resource controls which graphics demos will be launched by\n\ +the screensaver. See `man xscreensaver' or the web page for more details.\n\ +\n\ +For updates, check http://people.netscape.com/jwz/xscreensaver/\n\n", si->version); #ifdef NO_LOCKING @@ -299,7 +298,7 @@ get_screenhacks (saver_info *si) d = get_string_resource ("programs", "Programs"); - size = strlen (d); + size = d ? strlen (d) : 0; p->screenhacks = (char **) malloc (sizeof (char *) * hacks_size); p->screenhacks_count = 0; @@ -482,14 +481,12 @@ get_resources (saver_info *si) get_screenhacks (si); -#ifdef DEBUG if (p->debug_p) { XSynchronize(si->dpy, True); p->verbose_p = True; p->initial_delay = 0; } -#endif /* DEBUG */ } @@ -543,17 +540,51 @@ initialize_connection (saver_info *si, int argc, char **argv) si->db = XtDatabase (si->dpy); XtGetApplicationNameAndClass (si->dpy, &progname, &progclass); + if(strlen(progname) > 100) progname [99] = 0; /* keep it short. */ + db = si->db; /* resources.c needs this */ if (argc == 2 && !strcmp (argv[1], "-help")) do_help (si); -#ifdef DEBUG + else if (argc == 2 && !strcmp (argv[1], "-debug")) si->prefs.debug_p = True; /* no resource for this one, out of paranoia. */ -#endif /* DEBUG */ + else if (argc > 1) { - fprintf (stderr, "%s: unknown option %s\n", progname, argv [1]); + const char *s = argv[1]; + fprintf (stderr, "%s: unknown option \"%s\". Try \"-help\".\n", + progname, s); + + if (s[0] == '-' && s[1] == '-') s++; + if (!strcmp (s, "-activate") || + !strcmp (s, "-deactivate") || + !strcmp (s, "-cycle") || + !strcmp (s, "-next") || + !strcmp (s, "-prev") || + !strcmp (s, "-exit") || + !strcmp (s, "-restart") || + !strcmp (s, "-demo") || + !strcmp (s, "-lock") || + !strcmp (s, "-version") || + !strcmp (s, "-time")) + { + fprintf (stderr, "\n\ + However, %s is an option to the `xscreensaver-command' program.\n\ + The `xscreensaver' program is a daemon that runs in the background.\n\ + You control a running xscreensaver process by sending it messages\n\ + with `xscreensaver-command'. See the man pages for details,\n\ + or check the web page: http://people.netscape.com/jwz/xscreensaver/\n\n", + s); + + /* Since version 1.21 renamed the "-lock" option to "-lock-mode", + suggest that explicitly. */ + if (!strcmp (s, "-lock")) + fprintf (stderr, "\ + Or perhaps you meant either the \"-lock-mode\" or the\n\ + \"-lock-timeout \" options to xscreensaver?\n\n"); + } + exit (1); } get_resources (si); @@ -623,32 +654,34 @@ initialize (saver_info *si, int argc, char **argv) si->version [4] = 0; progname = argv[0]; /* reset later; this is for the benefit of lock_init() */ + if(strlen(progname) > 100) progname[99] = 0; /* keep it short. */ + #ifdef NO_LOCKING si->locking_disabled_p = True; si->nolock_reason = "not compiled with locking support"; -#else +#else /* !NO_LOCKING */ si->locking_disabled_p = False; -#ifdef SCO +# ifdef SCO set_auth_parameters(argc, argv); -#endif +# endif /* SCO */ if (! lock_init (argc, argv)) /* before hack_uid() for proper permissions */ { si->locking_disabled_p = True; si->nolock_reason = "error getting password"; } -#endif +#endif /* !NO_LOCKING */ #ifndef NO_SETUID hack_uid (si); -#endif +#endif /* NO_SETUID */ progclass = "XScreenSaver"; - /* remove -demo switch before saving argv */ + /* remove -initial-demo-mode switch before saving argv */ for (i = 1; i < argc; i++) - while (!strcmp ("-demo", argv [i])) + while (!strcmp ("-initial-demo-mode", argv [i])) { int j; initial_demo_mode_p = True; @@ -668,7 +701,10 @@ initialize (saver_info *si, int argc, char **argv) for (i = 0; i < si->nscreens; i++) - ensure_no_screensaver_running (si->dpy, si->screens[i].screen); + if (ensure_no_screensaver_running (si->dpy, si->screens[i].screen)) + exit (1); + + hack_environment (si); si->demo_mode_p = initial_demo_mode_p; srandom ((int) time ((time_t *) 0)); @@ -863,7 +899,7 @@ main_loop (saver_info *si) just after the server is grabbed, closing this window entirely. */ - /* ungrab_keyboard_and_mouse (); */ + /* ungrab_keyboard_and_mouse (si); */ { saver_screen_info *ssi = si->default_screen; @@ -881,7 +917,7 @@ main_loop (saver_info *si) /* I think this grab is now redundant, but it shouldn't hurt. */ if (!si->demo_mode_p) - grab_keyboard_and_mouse (si->dpy, ssi->screensaver_window, + grab_keyboard_and_mouse (si, ssi->screensaver_window, ssi->cursor); }