+ XA_BLANK = XInternAtom (si->dpy, "BLANK", False);
+ XA_THROTTLE = XInternAtom (si->dpy, "THROTTLE", False);
+ XA_UNTHROTTLE = XInternAtom (si->dpy, "UNTHROTTLE", False);
+
+ return toplevel_shell;
+}
+
+
+/* Handle the command-line arguments that were not handled for us by Xt.
+ Issue an error message and exit if there are unknown options.
+ */
+static void
+process_command_line (saver_info *si, int *argc, char **argv)
+{
+ int i;
+ for (i = 1; i < *argc; i++)
+ {
+ if (!strcmp (argv[i], "-debug"))
+ /* no resource for this one, out of paranoia. */
+ si->prefs.debug_p = True;
+
+ else if (!strcmp (argv[i], "-h") ||
+ !strcmp (argv[i], "-help") ||
+ !strcmp (argv[i], "--help"))
+ do_help (si);
+
+ else
+ {
+ const char *s = argv[i];
+ fprintf (stderr, "%s: unknown option \"%s\". Try \"-help\".\n",
+ blurb(), 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, "-prefs") ||
+ !strcmp (s, "-preferences") ||
+ !strcmp (s, "-lock") ||
+ !strcmp (s, "-version") ||
+ !strcmp (s, "-time"))
+ {
+
+ if (!strcmp (s, "-demo") || !strcmp (s, "-prefs"))
+ fprintf (stderr, "\n\
+ Perhaps you meant to run the `xscreensaver-demo' program instead?\n");
+ else
+ fprintf (stderr, "\n\
+ However, `%s' is an option to the `xscreensaver-command' program.\n", s);
+
+ fprintf (stderr, "\
+ 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-demo' or `xscreensaver-command'.\n\
+. See the man pages for details, or check the web page:\n\
+ http://www.jwz.org/xscreensaver/\n\n");
+
+ /* 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 <minutes>\" options to xscreensaver?\n\n");
+ }
+
+ exit (1);
+ }
+ }
+}
+
+
+/* Print out the xscreensaver banner to the tty if applicable;
+ Issue any other warnings that are called for at this point.
+ */
+static void
+print_banner (saver_info *si)
+{
+ saver_preferences *p = &si->prefs;
+
+ /* This resource gets set some time before the others, so that we know
+ whether to print the banner (and so that the banner gets printed before
+ any resource-database-related error messages.)
+ */
+ p->verbose_p = (p->debug_p || get_boolean_resource ("verbose", "Boolean"));
+
+ /* Ditto, for the locking_disabled_p message. */
+ p->lock_p = get_boolean_resource ("lock", "Boolean");
+
+ if (p->verbose_p)
+ fprintf (stderr,
+ "%s %s, copyright (c) 1991-1999 "
+ "by Jamie Zawinski <jwz@jwz.org>.\n",
+ progname, si->version);
+
+ if (p->debug_p)
+ fprintf (stderr, "\n"
+ "%s: Warning: running in DEBUG MODE. Be afraid.\n"
+ "\n"
+ "\tNote that in debug mode, the xscreensaver window will only\n"
+ "\tcover the left half of the screen. (The idea is that you\n"
+ "\tcan still see debugging output in a shell, if you position\n"
+ "\tit on the right side of the screen.)\n"
+ "\n"
+ "\tDebug mode is NOT SECURE. Do not run with -debug in\n"
+ "\tuntrusted environments.\n"
+ "\n",
+ blurb());
+
+ if (p->verbose_p)
+ {
+ if (!si->uid_message || !*si->uid_message)
+ describe_uids (si, stderr);
+ else
+ {
+ if (si->orig_uid && *si->orig_uid)
+ fprintf (stderr, "%s: initial effective uid/gid was %s.\n",
+ blurb(), si->orig_uid);
+ fprintf (stderr, "%s: %s\n", blurb(), si->uid_message);
+ }
+
+ fprintf (stderr, "%s: in process %lu.\n", blurb(),
+ (unsigned long) getpid());
+ }
+
+ /* If locking was not able to be initalized for some reason, explain why.
+ (This has to be done after we've read the lock_p resource.)
+ */
+ if (p->lock_p && si->locking_disabled_p)
+ {
+ p->lock_p = False;
+ fprintf (stderr, "%s: locking is disabled (%s).\n", blurb(),
+ si->nolock_reason);
+ if (strstr (si->nolock_reason, "passw"))
+ fprintf (stderr, "%s: does xscreensaver need to be setuid? "
+ "consult the manual.\n", blurb());
+ else if (strstr (si->nolock_reason, "running as "))
+ fprintf (stderr,
+ "%s: locking only works when xscreensaver is launched\n"
+ "\t by a normal, non-privileged user (e.g., not \"root\".)\n"
+ "\t See the manual for details.\n",
+ blurb());
+ }
+}
+
+
+/* Examine all of the display's screens, and populate the `saver_screen_info'
+ structures.
+ */
+static void
+initialize_per_screen_info (saver_info *si, Widget toplevel_shell)
+{
+ Bool found_any_writable_cells = False;
+ int i;