X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=driver%2Ftimers.c;h=c909287cc2968290ced54bb7fb8cb2b173df555a;hp=aba6d5a3f0d421973fa1b3ef198ae9ce6bb0d13d;hb=c31d10b6605cd8dc1a7b61fef4256f06198767e5;hpb=2a991a811de4c7b22f812682b267b616a809fd9a diff --git a/driver/timers.c b/driver/timers.c index aba6d5a3..c909287c 100644 --- a/driver/timers.c +++ b/driver/timers.c @@ -242,7 +242,8 @@ reset_timers (saver_info *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 (); /* no cycle timer when inactive */ @@ -468,11 +469,25 @@ sleep_until_idle (saver_info *si, Bool until_idle_p) /* If any widgets want to handle this event, let them. */ 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) + /* 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: @@ -484,15 +499,13 @@ sleep_until_idle (saver_info *si, Bool until_idle_p) (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]; @@ -504,11 +517,9 @@ sleep_until_idle (saver_info *si, Bool until_idle_p) 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) @@ -516,20 +527,16 @@ sleep_until_idle (saver_info *si, Bool 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 @@ -539,11 +546,9 @@ sleep_until_idle (saver_info *si, Bool until_idle_p) #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; @@ -551,11 +556,9 @@ sleep_until_idle (saver_info *si, Bool until_idle_p) 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; } @@ -620,29 +623,28 @@ static void 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); } } }