X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=driver%2Ftimers.c;h=a0d2392c33e26b36e8f5cfead384d3c4c9ad9619;hb=3210e7e80ee2b5a7d2049a5aaff9f17b9c93dcc9;hp=77bc8c30fd20b45964ecf2d593324657d6909064;hpb=ce3185de9d9705e259f2b60dd4b5509007fa17d4;p=xscreensaver diff --git a/driver/timers.c b/driver/timers.c index 77bc8c30..a0d2392c 100644 --- a/driver/timers.c +++ b/driver/timers.c @@ -181,7 +181,7 @@ cycle_timer (XtPointer closure, XtIntervalId *id) 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", @@ -190,6 +190,7 @@ cycle_timer (XtPointer closure, XtIntervalId *id) } else { + maybe_reload_init_file (si); if (p->verbose_p) fprintf (stderr, "%s: changing graphics hacks.\n", blurb()); kill_screenhack (si); @@ -232,7 +233,7 @@ static void reset_timers (saver_info *si) { saver_preferences *p = &si->prefs; - if (p->use_mit_saver_extension || p->use_sgi_saver_extension) + if (si->using_mit_saver_extension || si->using_sgi_saver_extension) return; #ifdef DEBUG_TIMERS @@ -241,10 +242,11 @@ 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 (); + if (si->cycle_id) abort (); /* no cycle timer when inactive */ #ifdef DEBUG_TIMERS if (p->verbose_p) @@ -267,9 +269,10 @@ check_pointer_timer (XtPointer closure, XtIntervalId *id) saver_preferences *p = &si->prefs; Bool active_p = False; - if (p->use_xidle_extension || - p->use_mit_saver_extension || - p->use_sgi_saver_extension) + if (si->using_xidle_extension || + si->using_mit_saver_extension || + si->using_sgi_saver_extension) + /* If an extension is in use, we should not be polling the mouse. */ abort (); si->check_pointer_timer_id = @@ -318,6 +321,20 @@ check_pointer_timer (XtPointer closure, XtIntervalId *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) { @@ -326,7 +343,7 @@ sleep_until_idle (saver_info *si, Bool until_idle_p) if (until_idle_p) { - if (!p->use_mit_saver_extension && !p->use_sgi_saver_extension) + if (!si->using_mit_saver_extension && !si->using_sgi_saver_extension) { /* Wake up periodically to ask the server if we are idle. */ si->timer_id = XtAppAddTimeOut (si->app, p->timeout, idle_timer, @@ -339,9 +356,9 @@ sleep_until_idle (saver_info *si, Bool until_idle_p) #endif /* DEBUG_TIMERS */ } - if (!p->use_xidle_extension && - !p->use_mit_saver_extension && - !p->use_sgi_saver_extension) + if (!si->using_xidle_extension && + !si->using_mit_saver_extension && + !si->using_sgi_saver_extension) /* start polling the mouse position */ check_pointer_timer ((XtPointer) si, 0); } @@ -356,7 +373,7 @@ sleep_until_idle (saver_info *si, Bool until_idle_p) { Time idle; #ifdef HAVE_XIDLE_EXTENSION - if (p->use_xidle_extension) + if (si->using_xidle_extension) { if (! XGetIdleTime (si->dpy, &idle)) { @@ -367,7 +384,7 @@ sleep_until_idle (saver_info *si, Bool until_idle_p) else #endif /* HAVE_XIDLE_EXTENSION */ #ifdef HAVE_MIT_SAVER_EXTENSION - if (p->use_mit_saver_extension) + if (si->using_mit_saver_extension) { /* We don't need to do anything in this case - the synthetic event isn't necessary, as we get sent specific events @@ -377,7 +394,7 @@ sleep_until_idle (saver_info *si, Bool until_idle_p) else #endif /* HAVE_MIT_SAVER_EXTENSION */ #ifdef HAVE_SGI_SAVER_EXTENSION - if (p->use_sgi_saver_extension) + if (si->using_sgi_saver_extension) { /* We don't need to do anything in this case - the synthetic event isn't necessary, as we get sent specific events @@ -392,8 +409,8 @@ sleep_until_idle (saver_info *si, Bool until_idle_p) if (idle >= p->timeout) goto DONE; - else if (!p->use_mit_saver_extension && - !p->use_sgi_saver_extension) + else if (!si->using_mit_saver_extension && + !si->using_sgi_saver_extension) { si->timer_id = XtAppAddTimeOut (si->app, p->timeout - idle, idle_timer, (XtPointer) si); @@ -412,9 +429,9 @@ sleep_until_idle (saver_info *si, Bool until_idle_p) break; case CreateNotify: - if (!p->use_xidle_extension && - !p->use_mit_saver_extension && - !p->use_sgi_saver_extension) + if (!si->using_xidle_extension && + !si->using_mit_saver_extension && + !si->using_sgi_saver_extension) { start_notice_events_timer (si, event.xcreatewindow.window); #ifdef DEBUG_TIMERS @@ -450,13 +467,29 @@ 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: @@ -468,15 +501,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]; @@ -488,11 +519,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) @@ -500,20 +529,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 @@ -523,11 +548,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; @@ -535,18 +558,16 @@ 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; } else #endif /* HAVE_SGI_SAVER_EXTENSION */ - XtDispatchEvent (&event); + dispatch_event (si, &event); } } DONE: @@ -575,7 +596,7 @@ sleep_until_idle (saver_info *si, Bool until_idle_p) 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; @@ -604,29 +625,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); } } }