saver_info *si = (saver_info *) closure;
saver_preferences *p = &si->prefs;
Time how_long = p->cycle;
- if (si->dbox_up_p || si->question_up_p)
+ if (si->dbox_up_p)
{
if (p->verbose_p)
fprintf (stderr, "%s: dialog box up; delaying hack change.\n",
}
else
{
+ maybe_reload_init_file (si);
if (p->verbose_p)
fprintf (stderr, "%s: changing graphics hacks.\n", blurb());
kill_screenhack (si);
blurb(), p->timeout, si->timer_id);
#endif /* DEBUG_TIMERS */
- XtRemoveTimeOut (si->timer_id);
+ if (si->timer_id)
+ XtRemoveTimeOut (si->timer_id);
si->timer_id = XtAppAddTimeOut (si->app, p->timeout, idle_timer,
(XtPointer) si);
- if (si->cycle_id) abort ();
+ if (si->cycle_id) abort (); /* no cycle timer when inactive */
#ifdef DEBUG_TIMERS
if (p->verbose_p)
if (p->use_xidle_extension ||
p->use_mit_saver_extension ||
p->use_sgi_saver_extension)
+ /* If an extension is in use, we should not be polling the mouse. */
abort ();
si->check_pointer_timer_id =
}
+static void
+dispatch_event (saver_info *si, XEvent *event)
+{
+ /* If this is for the splash dialog, pass it along.
+ Note that the password dialog is handled with its own event loop,
+ so events for that window will never come through here.
+ */
+ if (si->splash_dialog && event->xany.window == si->splash_dialog)
+ handle_splash_event (si, event);
+
+ XtDispatchEvent (event);
+}
+
+
void
sleep_until_idle (saver_info *si, Bool until_idle_p)
{
#endif /* DEBUG_TIMERS */
/* If any widgets want to handle this event, let them. */
- XtDispatchEvent (&event);
+ dispatch_event (si, &event);
- /* We got a user event */
+ /* We got a user event.
+ If we're waiting for the user to become active, this is it.
+ If we're waiting until the user becomes idle, reset the timers
+ (since now we have longer to wait.)
+ */
if (!until_idle_p)
- goto DONE;
+ {
+ if (si->demoing_p &&
+ (event.xany.type == MotionNotify ||
+ event.xany.type == KeyRelease))
+ /* When we're demoing a single hack, mouse motion doesn't
+ cause deactivation. Only clicks and keypresses do. */
+ ;
+ else
+ /* If we're not demoing, then any activity causes deactivation.
+ */
+ goto DONE;
+ }
else
reset_timers (si);
+
break;
default:
(XScreenSaverNotifyEvent *) &event;
if (sevent->state == ScreenSaverOn)
{
-# ifdef DEBUG_TIMERS
+ int i = 0;
if (p->verbose_p)
- fprintf (stderr, "%s: ScreenSaverOn event received at %s\n",
- blurb(), timestring ());
-# endif /* DEBUG_TIMERS */
+ fprintf (stderr, "%s: MIT ScreenSaverOn event received.\n",
+ blurb());
/* Get the "real" server window(s) out of the way as soon
as possible. */
- int i = 0;
for (i = 0; i < si->nscreens; i++)
{
saver_screen_info *ssi = &si->screens[i];
if (sevent->kind != ScreenSaverExternal)
{
-# ifdef DEBUG_TIMERS
fprintf (stderr,
"%s: ScreenSaverOn event wasn't of type External!\n",
blurb());
-# endif /* DEBUG_TIMERS */
}
if (until_idle_p)
}
else if (sevent->state == ScreenSaverOff)
{
-# ifdef DEBUG_TIMERS
if (p->verbose_p)
- fprintf (stderr, "%s: ScreenSaverOff event received at %s\n",
- blurb(), timestring ());
-# endif /* DEBUG_TIMERS */
+ fprintf (stderr, "%s: MIT ScreenSaverOff event received.\n",
+ blurb());
if (!until_idle_p)
goto DONE;
}
-# ifdef DEBUG_TIMERS
- else if (p->verbose_p)
+ else
fprintf (stderr,
- "%s: unknown MIT-SCREEN-SAVER event received at %s\n",
- blurb(), timestring ());
-# endif /* DEBUG_TIMERS */
+ "%s: unknown MIT-SCREEN-SAVER event %d received!\n",
+ blurb(), sevent->state);
}
else
#ifdef HAVE_SGI_SAVER_EXTENSION
if (event.type == (si->sgi_saver_ext_event_number + ScreenSaverStart))
{
-# ifdef DEBUG_TIMERS
if (p->verbose_p)
- fprintf (stderr, "%s: ScreenSaverStart event received at %s\n",
- blurb(), timestring ());
-# endif /* DEBUG_TIMERS */
+ fprintf (stderr, "%s: SGI ScreenSaverStart event received.\n",
+ blurb());
if (until_idle_p)
goto DONE;
else if (event.type == (si->sgi_saver_ext_event_number +
ScreenSaverEnd))
{
-# ifdef DEBUG_TIMERS
if (p->verbose_p)
- fprintf (stderr, "%s: ScreenSaverEnd event received at %s\n",
- blurb(), timestring ());
-# endif /* DEBUG_TIMERS */
+ fprintf (stderr, "%s: SGI ScreenSaverEnd event received.\n",
+ blurb());
if (!until_idle_p)
goto DONE;
}
else
#endif /* HAVE_SGI_SAVER_EXTENSION */
- XtDispatchEvent (&event);
+ dispatch_event (si, &event);
}
}
DONE:
si->timer_id = 0;
}
- if (until_idle_p && si->cycle_id)
+ if (until_idle_p && si->cycle_id) /* no cycle timer when inactive */
abort ();
return;
watchdog_timer (XtPointer closure, XtIntervalId *id)
{
saver_info *si = (saver_info *) closure;
- if (!si->demo_mode_p)
+
+ disable_builtin_screensaver (si, False);
+
+ if (si->screen_blanked_p)
{
- disable_builtin_screensaver (si, False);
- if (si->screen_blanked_p)
- {
- Bool running_p = screenhack_running_p(si);
+ Bool running_p = screenhack_running_p(si);
#ifdef DEBUG_TIMERS
- if (si->prefs.verbose_p)
- fprintf (stderr, "%s: watchdog timer raising %sscreen.\n",
- blurb(), (running_p ? "" : "and clearing "));
+ if (si->prefs.verbose_p)
+ fprintf (stderr, "%s: watchdog timer raising %sscreen.\n",
+ blurb(), (running_p ? "" : "and clearing "));
#endif /* DEBUG_TIMERS */
- raise_window (si, True, True, running_p);
+ raise_window (si, True, True, running_p);
- if (!monitor_powered_on_p (si))
- {
- if (si->prefs.verbose_p)
- fprintf (stderr,
- "%s: server reports that monitor has powered down; "
- "killing running hacks.\n", blurb());
- kill_screenhack (si);
- }
+ if (!monitor_powered_on_p (si))
+ {
+ if (si->prefs.verbose_p)
+ fprintf (stderr,
+ "%s: server reports that monitor has powered down; "
+ "killing running hacks.\n", blurb());
+ kill_screenhack (si);
}
}
}