X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=driver%2Ftimers.c;h=f2fdb24b9119205df6d5d850fcb0fbe52788b156;hb=3c58fb6311db49c46f1670922933b27c6ea0c065;hp=ef5d54331707332d30f1da63947d640ae3ddffa4;hpb=278c59e14c53fd412b734e699bd4f314f766f804;p=xscreensaver diff --git a/driver/timers.c b/driver/timers.c index ef5d5433..f2fdb24b 100644 --- a/driver/timers.c +++ b/driver/timers.c @@ -43,11 +43,6 @@ #include #endif /* HAVE_SGI_SAVER_EXTENSION */ -#ifdef HAVE_XHPDISABLERESET -# include - extern Bool hp_locked_p; /* from windows.c */ -#endif /* HAVE_XHPDISABLERESET */ - #include "xscreensaver.h" #ifdef HAVE_PROC_INTERRUPTS @@ -235,8 +230,6 @@ 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); if (!si->throttled_p) @@ -250,14 +243,25 @@ cycle_timer (XtPointer closure, XtIntervalId *id) } } - si->cycle_id = XtAppAddTimeOut (si->app, how_long, cycle_timer, - (XtPointer) si); + if (how_long > 0) + { + si->cycle_id = XtAppAddTimeOut (si->app, how_long, cycle_timer, + (XtPointer) si); -#ifdef DEBUG_TIMERS - if (p->verbose_p) - fprintf (stderr, "%s: starting cycle_timer (%ld, %ld)\n", - blurb(), how_long, si->cycle_id); -#endif /* DEBUG_TIMERS */ +# ifdef DEBUG_TIMERS + if (p->verbose_p) + fprintf (stderr, "%s: starting cycle_timer (%ld, %ld)\n", + blurb(), how_long, si->cycle_id); +# endif /* DEBUG_TIMERS */ + } +# ifdef DEBUG_TIMERS + else + { + if (p->verbose_p) + fprintf (stderr, "%s: not starting cycle_timer: how_long == %d\n", + blurb(), how_long); + } +# endif /* DEBUG_TIMERS */ } @@ -269,15 +273,7 @@ activate_lock_timer (XtPointer closure, XtIntervalId *id) if (p->verbose_p) fprintf (stderr, "%s: timed out; activating lock.\n", blurb()); - si->locked_p = True; - -#ifdef HAVE_XHPDISABLERESET - if (!hp_locked_p) - { - XHPDisableReset (si->dpy); /* turn off C-Sh-Reset */ - hp_locked_p = True; - } -#endif + set_locked_p (si, True); } @@ -361,6 +357,16 @@ check_pointer_timer (XtPointer closure, XtIntervalId *id) else fprintf (stderr, "%s: pointer moved at %s on screen %d.\n", blurb(), timestring(), i); + +# if 0 + fprintf (stderr, "%s: old: %d %d 0x%x ; new: %d %d 0x%x\n", + blurb(), + ssi->poll_mouse_last_root_x, + ssi->poll_mouse_last_root_y, + (unsigned int) ssi->poll_mouse_last_child, + root_x, root_y, (unsigned int) child); +# endif /* 0 */ + #endif /* DEBUG_TIMERS */ si->last_activity_screen = ssi; @@ -453,6 +459,63 @@ dispatch_event (saver_info *si, XEvent *event) } +static void +swallow_unlock_typeahead_events (saver_info *si, XEvent *e) +{ + XEvent event; + char buf [100]; + int i = 0; + + memset (buf, 0, sizeof(buf)); + + event = *e; + + do + { + if (event.xany.type == KeyPress) + { + char s[2]; + int size = XLookupString ((XKeyEvent *) &event, s, 1, 0, 0); + if (size != 1) continue; + switch (*s) + { + case '\010': case '\177': /* Backspace */ + if (i > 0) i--; + break; + case '\025': case '\030': /* Erase line */ + case '\012': case '\015': /* Enter */ + i = 0; + break; + case '\040': /* Space */ + if (i == 0) + break; /* ignore space at beginning of line */ + /* else, fall through */ + default: + buf [i++] = *s; + break; + } + } + + } while (i < sizeof(buf)-1 && + XCheckMaskEvent (si->dpy, KeyPressMask, &event)); + + buf[i] = 0; + + if (si->unlock_typeahead) + { + memset (si->unlock_typeahead, 0, strlen(si->unlock_typeahead)); + free (si->unlock_typeahead); + } + + if (i > 0) + si->unlock_typeahead = strdup (buf); + else + si->unlock_typeahead = 0; + + memset (buf, 0, sizeof(buf)); +} + + /* methods of detecting idleness: explicitly informed by SGI SCREEN_SAVER server event; @@ -765,8 +828,13 @@ sleep_until_idle (saver_info *si, Bool until_idle_p) doesn't exhibit itself without an extension, because in that case, there's only one event generated by user activity, not two.) */ - XCheckMaskEvent (si->dpy, (KeyPressMask|ButtonPressMask|PointerMotionMask), - &event); + if (!until_idle_p && si->locked_p) + swallow_unlock_typeahead_events (si, &event); + else + while (XCheckMaskEvent (si->dpy, + (KeyPressMask|ButtonPressMask|PointerMotionMask), + &event)) + ; if (si->check_pointer_timer_id) @@ -1014,9 +1082,18 @@ static void watchdog_timer (XtPointer closure, XtIntervalId *id) { saver_info *si = (saver_info *) closure; + saver_preferences *p = &si->prefs; disable_builtin_screensaver (si, False); + /* If the DPMS settings on the server have changed, change them back to + what ~/.xscreensaver says they should be. */ + sync_server_dpms_settings (si->dpy, p->dpms_enabled_p, + p->dpms_standby / 1000, + p->dpms_suspend / 1000, + p->dpms_off / 1000, + False); + if (si->screen_blanked_p) { Bool running_p = screenhack_running_p (si); @@ -1040,11 +1117,12 @@ watchdog_timer (XtPointer closure, XtIntervalId *id) raise_window (si, True, True, running_p); } - if (!monitor_powered_on_p (si)) + if (screenhack_running_p (si) && + !monitor_powered_on_p (si)) { if (si->prefs.verbose_p) fprintf (stderr, - "%s: server reports that monitor has powered down; " + "%s: X says monitor has powered down; " "killing running hacks.\n", blurb()); kill_screenhack (si); }