- if (! p->fade_p) p->unfade_p = False;
-
- p->watchdog_timeout = p->cycle;
- if (p->watchdog_timeout < 30000) p->watchdog_timeout = 30000; /* 30 secs */
- if (p->watchdog_timeout > 3600000) p->watchdog_timeout = 3600000; /* 1 hr */
-
-#ifdef NO_LOCKING
- si->locking_disabled_p = True;
- si->nolock_reason = "not compiled with locking support";
- if (p->lock_p)
- {
- p->lock_p = False;
- fprintf (stderr, "%s: not compiled with support for locking.\n",
- progname);
- }
-#else /* ! NO_LOCKING */
- if (p->lock_p && si->locking_disabled_p)
- {
- fprintf (stderr, "%s: locking is disabled (%s).\n", progname,
- si->nolock_reason);
- p->lock_p = False;
- }
-#endif /* ! NO_LOCKING */
-
- get_screenhacks (si);
-
-#ifdef DEBUG
- if (p->debug_p)
- {
- XSynchronize(si->dpy, True);
- p->verbose_p = True;
- p->initial_delay = 0;
- }
-#endif /* DEBUG */
-}
-
-
-char *
-timestring (void)
-{
- time_t now = time ((time_t *) 0);
- char *str = (char *) ctime (&now);
- char *nl = (char *) strchr (str, '\n');
- if (nl) *nl = 0; /* take off that dang newline */
- return str;
-}
-
-static void initialize (saver_info *si, int argc, char **argv);
-static void main_loop (saver_info *si);
-
-int
-main (int argc, char **argv)
-{
- saver_info si;
- memset(&si, 0, sizeof(si));
- global_si_kludge = &si; /* I hate C so much... */
- initialize (&si, argc, argv);
- main_loop (&si); /* doesn't return */
- return 0;
-}
-
-
-int
-saver_ehandler (Display *dpy, XErrorEvent *error)
-{
- saver_info *si = global_si_kludge; /* I hate C so much... */
-
- fprintf (real_stderr, "\nX error in %s:\n", progname);
- if (XmuPrintDefaultErrorMessage (dpy, error, real_stderr))
- saver_exit (si, -1);
- else
- fprintf (real_stderr, " (nonfatal.)\n");
- return 0;
-}
-
-static void
-initialize_connection (saver_info *si, int argc, char **argv)
-{
- int i;
- Widget toplevel_shell = XtAppInitialize (&si->app, progclass,
- options, XtNumber (options),
- &argc, argv, defaults, 0, 0);
-
- si->dpy = XtDisplay (toplevel_shell);
- si->db = XtDatabase (si->dpy);
- XtGetApplicationNameAndClass (si->dpy, &progname, &progclass);
-
- 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]);
- exit (1);
- }
- get_resources (si);
-#ifndef NO_SETUID
- hack_uid_warn (si);
-#endif /* NO_SETUID */
- XA_VROOT = XInternAtom (si->dpy, "__SWM_VROOT", False);
- XA_SCREENSAVER = XInternAtom (si->dpy, "SCREENSAVER", False);
- XA_SCREENSAVER_VERSION = XInternAtom (si->dpy, "_SCREENSAVER_VERSION",False);
- XA_SCREENSAVER_ID = XInternAtom (si->dpy, "_SCREENSAVER_ID", False);
- XA_SCREENSAVER_TIME = XInternAtom (si->dpy, "_SCREENSAVER_TIME", False);
- XA_XSETROOT_ID = XInternAtom (si->dpy, "_XSETROOT_ID", False);
- XA_ACTIVATE = XInternAtom (si->dpy, "ACTIVATE", False);
- XA_DEACTIVATE = XInternAtom (si->dpy, "DEACTIVATE", False);
- XA_RESTART = XInternAtom (si->dpy, "RESTART", False);
- XA_CYCLE = XInternAtom (si->dpy, "CYCLE", False);
- XA_NEXT = XInternAtom (si->dpy, "NEXT", False);
- XA_PREV = XInternAtom (si->dpy, "PREV", False);
- XA_EXIT = XInternAtom (si->dpy, "EXIT", False);
- XA_DEMO = XInternAtom (si->dpy, "DEMO", False);
- XA_LOCK = XInternAtom (si->dpy, "LOCK", False);
-
- si->nscreens = ScreenCount(si->dpy);
- si->screens = (saver_screen_info *)
- calloc(sizeof(saver_screen_info), si->nscreens);
-
- si->default_screen = &si->screens[DefaultScreen(si->dpy)];
-
- for (i = 0; i < si->nscreens; i++)
- {
- saver_screen_info *ssi = &si->screens[i];
- ssi->global = si;
- ssi->screen = ScreenOfDisplay (si->dpy, i);
-
- /* Note: we can't use the resource ".visual" because Xt is SO FUCKED. */
- ssi->default_visual =
- get_visual_resource (ssi->screen, "visualID", "VisualID", False);
-
- ssi->current_visual = ssi->default_visual;
- ssi->current_depth = visual_depth (ssi->screen, ssi->current_visual);
-
- if (ssi == si->default_screen)
- /* Since this is the default screen, use the one already created. */
- ssi->toplevel_shell = toplevel_shell;
- else
- /* Otherwise, each screen must have its own unmapped root widget. */
- ssi->toplevel_shell =
- XtVaAppCreateShell(progname, progclass, applicationShellWidgetClass,
- si->dpy,
- XtNscreen, ssi->screen,
- XtNvisual, ssi->current_visual,
- XtNdepth, visual_depth(ssi->screen,
- ssi->current_visual),
- 0);
- }
-}
-
-
-static void
-initialize (saver_info *si, int argc, char **argv)
-{
- int i;
- saver_preferences *p = &si->prefs;
- Bool initial_demo_mode_p = False;
- si->version = (char *) malloc (5);
- memcpy (si->version, screensaver_id + 17, 4);
- si->version [4] = 0;
- progname = argv[0]; /* reset later; this is for the benefit of lock_init() */