X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=driver%2Ftimers.c;h=9ab7ae6e050586f2620f9502721b1c99da7a131d;hb=7b34ef992563d7bcbb64cc5597dc45fa24470b05;hp=c9244f735e7655b29c8a968a7175d7885e364b78;hpb=447db08c956099b3b183886729108bf5b364c4b8;p=xscreensaver diff --git a/driver/timers.c b/driver/timers.c index c9244f73..9ab7ae6e 100644 --- a/driver/timers.c +++ b/driver/timers.c @@ -1,5 +1,5 @@ /* timers.c --- detecting when the user is idle, and other timer-related tasks. - * xscreensaver, Copyright (c) 1991-2004 Jamie Zawinski + * xscreensaver, Copyright (c) 1991-2008 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -264,14 +264,18 @@ cycle_timer (XtPointer closure, XtIntervalId *id) } else { + int i; maybe_reload_init_file (si); - kill_screenhack (si); + for (i = 0; i < si->nscreens; i++) + kill_screenhack (&si->screens[i]); + + raise_window (si, True, True, False); if (!si->throttled_p) - spawn_screenhack (si, False); + for (i = 0; i < si->nscreens; i++) + spawn_screenhack (&si->screens[i]); else { - raise_window (si, True, True, False); if (p->verbose_p) fprintf (stderr, "%s: not launching new hack (throttled.)\n", blurb()); @@ -331,6 +335,23 @@ reset_timers (saver_info *si) if (si->cycle_id) abort (); /* no cycle timer when inactive */ si->last_activity_time = time ((time_t *) 0); + + /* This will (hopefully, supposedly) tell the server to re-set its + DPMS timer. Without this, the -deactivate clientmessage would + prevent xscreensaver from blanking, but would not prevent the + monitor from powering down. */ +#if 0 + /* #### With some servers, this causes the screen to flicker every + time a key is pressed! Ok, I surrender. I give up on ever + having DPMS work properly. + */ + XForceScreenSaver (si->dpy, ScreenSaverReset); + + /* And if the monitor is already powered off, turn it on. + You'd think the above would do that, but apparently not? */ + monitor_power_on (si); +#endif + } @@ -386,11 +407,17 @@ pointer_moved_p (saver_screen_info *ssi, Bool mods_p) distance > 0) moved_p = True; - if (ssi->poll_mouse_last_root_x == -1 || - ssi->poll_mouse_last_root_y == -1 || - root_x == -1 || - root_y == -1) - moved_p = True; + /* If the mouse is not on this screen but used to be, that's motion. + If the mouse was not on this screen, but is now, that's motion. + */ + { + Bool on_screen_p = (root_x != -1 && root_y != -1); + Bool was_on_screen_p = (ssi->poll_mouse_last_root_x != -1 && + ssi->poll_mouse_last_root_y != -1); + + if (on_screen_p != was_on_screen_p) + moved_p = True; + } if (p->debug_p && (distance != 0 || moved_p)) { @@ -404,7 +431,7 @@ pointer_moved_p (saver_screen_info *ssi, Bool mods_p) ssi->poll_mouse_last_root_y); fprintf (stderr, " -> "); if (root_x == -1) - fprintf (stderr, "off screen."); + fprintf (stderr, "off screen"); else fprintf (stderr, "%d,%d", root_x, root_y); if (ssi->poll_mouse_last_root_x != -1 && root_x != -1) @@ -585,6 +612,7 @@ swallow_unlock_typeahead_events (saver_info *si, XEvent *e) break; case '\025': case '\030': /* Erase line */ case '\012': case '\015': /* Enter */ + case '\033': /* ESC */ i = 0; break; case '\040': /* Space */ @@ -790,9 +818,12 @@ sleep_until_idle (saver_info *si, Bool until_idle_p) break; case KeyPress: - case KeyRelease: case ButtonPress: - case ButtonRelease: + /* Ignore release events so that hitting ESC at the password dialog + doesn't result in the password dialog coming right back again when + the fucking release key is seen! */ + /* case KeyRelease:*/ + /* case ButtonRelease:*/ case MotionNotify: if (p->debug_p) @@ -987,28 +1018,17 @@ sleep_until_idle (saver_info *si, Bool until_idle_p) if (event.type == (si->randr_event_number + RRScreenChangeNotify)) { /* The Resize and Rotate extension sends an event when the - size, rotation, or refresh rate of the screen has changed. */ - + size, rotation, or refresh rate of any screen has changed. + */ XRRScreenChangeNotifyEvent *xrr_event = (XRRScreenChangeNotifyEvent *) &event; - /* XRRRootToScreen is in Xrandr.h 1.4, 2001/06/07 */ - int screen = XRRRootToScreen (si->dpy, xrr_event->window); if (p->verbose_p) { - if (si->screens[screen].width == xrr_event->width && - si->screens[screen].height == xrr_event->height) - fprintf (stderr, - "%s: %d: no-op screen size change event (%dx%d)\n", - blurb(), screen, - xrr_event->width, xrr_event->height); - else - fprintf (stderr, - "%s: %d: screen size changed from %dx%d to %dx%d\n", - blurb(), screen, - si->screens[screen].width, - si->screens[screen].height, - xrr_event->width, xrr_event->height); + /* XRRRootToScreen is in Xrandr.h 1.4, 2001/06/07 */ + int screen = XRRRootToScreen (si->dpy, xrr_event->window); + fprintf (stderr, "%s: %d: screen change event received\n", + blurb(), screen); } # ifdef RRScreenChangeNotifyMask @@ -1017,7 +1037,15 @@ sleep_until_idle (saver_info *si, Bool until_idle_p) # endif /* RRScreenChangeNotifyMask */ /* Resize the existing xscreensaver windows and cached ssi data. */ - resize_screensaver_window (si); + if (update_screen_layout (si)) + { + if (p->verbose_p) + { + fprintf (stderr, "%s: new layout:\n", blurb()); + describe_monitor_layout (si); + } + resize_screensaver_window (si); + } } else #endif /* HAVE_RANDR */ @@ -1059,8 +1087,6 @@ sleep_until_idle (saver_info *si, Bool until_idle_p) if (until_idle_p && si->cycle_id) /* no cycle timer when inactive */ abort (); - - return; } @@ -1170,7 +1196,10 @@ query_proc_interrupts_available (saver_info *si, const char **why) f = fopen (PROC_INTERRUPTS, "r"); if (!f) - return False; + { + if (why) *why = "does not exist"; + return False; + } fclose (f); return True; @@ -1375,11 +1404,13 @@ watchdog_timer (XtPointer closure, XtIntervalId *id) if (screenhack_running_p (si) && !monitor_powered_on_p (si)) { + int i; if (si->prefs.verbose_p) fprintf (stderr, "%s: X says monitor has powered down; " "killing running hacks.\n", blurb()); - kill_screenhack (si); + for (i = 0; i < si->nscreens; i++) + kill_screenhack (&si->screens[i]); } /* Re-schedule this timer. The watchdog timer defaults to a bit less