X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=driver%2Fxscreensaver.c;h=d7478378a3da5e7d561252724fc57c152a8f23cf;hb=d1ae2829ff0fd2a96c16a0c8c5420efaa47d7b30;hp=ed5bf3032fbc7e86b1c477c304ae22dc23491b7f;hpb=6f5482d73adb0165c0130bb47d852644ab0c4869;p=xscreensaver diff --git a/driver/xscreensaver.c b/driver/xscreensaver.c index ed5bf303..d7478378 100644 --- a/driver/xscreensaver.c +++ b/driver/xscreensaver.c @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 1991-2012 Jamie Zawinski +/* xscreensaver, Copyright (c) 1991-2014 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 @@ -93,6 +93,14 @@ * subwindows. It is an incredible misdesign that one client can make * another client malfunction in this way. * + * But here's a new kink that started showing up in late 2014: GNOME programs + * don't actually select for or receive KeyPress events! They do it behind + * the scenes through some kind of Input Method magic, even when running in + * an en_US locale. However, in that case, those applications *do* seem to + * update the _NET_WM_USER_TIME on their own windows every time they have + * received a secret KeyPress, so we *also* monitor that property on every + * window, and treat changes to it as identical to KeyPress. + * * To detect mouse motion, we periodically wake up and poll the mouse * position and button/modifier state, and notice when something has * changed. We make this check every five seconds by default, and since the @@ -271,17 +279,24 @@ ERROR! You must not include vroot.h in this file. static void do_help (saver_info *si) { + char *s, year[5]; + s = strchr (screensaver_id, '-'); + s = strrchr (s, '-'); + s++; + strncpy (year, s, 4); + year[4] = 0; + fflush (stdout); fflush (stderr); fprintf (stdout, "\ -xscreensaver %s, copyright (c) 1991-2008 by Jamie Zawinski \n\ +xscreensaver %s, copyright (c) 1991-%s by Jamie Zawinski \n\ \n\ All xscreensaver configuration is via the `~/.xscreensaver' file.\n\ Rather than editing that file by hand, just run `xscreensaver-demo':\n\ that program lets you configure the screen saver graphically,\n\ including timeouts, locking, and display modes.\n\ \n", - si->version); + si->version, year); fprintf (stdout, "\ Just getting started? Try this:\n\ \n\ @@ -652,6 +667,7 @@ connect_to_server (saver_info *si, int *argc, char **argv) XA_XSETROOT_ID = XInternAtom (si->dpy, "_XSETROOT_ID", False); XA_ESETROOT_PMAP_ID = XInternAtom (si->dpy, "ESETROOT_PMAP_ID", False); XA_XROOTPMAP_ID = XInternAtom (si->dpy, "_XROOTPMAP_ID", False); + XA_NET_WM_USER_TIME = XInternAtom (si->dpy, "_NET_WM_USER_TIME", False); XA_ACTIVATE = XInternAtom (si->dpy, "ACTIVATE", False); XA_DEACTIVATE = XInternAtom (si->dpy, "DEACTIVATE", False); XA_RESTART = XInternAtom (si->dpy, "RESTART", False); @@ -740,6 +756,13 @@ print_banner (saver_info *si) { saver_preferences *p = &si->prefs; + char *s, year[5]; + s = strchr (screensaver_id, '-'); + s = strrchr (s, '-'); + s++; + strncpy (year, s, 4); + year[4] = 0; + /* This resource gets set some time before the others, so that we know whether to print the banner (and so that the banner gets printed before any resource-database-related error messages.) @@ -752,9 +775,9 @@ print_banner (saver_info *si) if (p->verbose_p) fprintf (stderr, - "%s %s, copyright (c) 1991-2008 " + "%s %s, copyright (c) 1991-%s " "by Jamie Zawinski .\n", - progname, si->version); + progname, si->version, year); if (p->debug_p) fprintf (stderr, "\n" @@ -770,6 +793,17 @@ print_banner (saver_info *si) "\n", blurb()); + if (p->verbose_p && senescent_p ()) + fprintf (stderr, "\n" + "*************************************" + "**************************************\n" + "%s: Warning: this version of xscreensaver is VERY OLD!\n" + "%s: Please upgrade! http://www.jwz.org/xscreensaver/\n" + "*************************************" + "**************************************\n" + "\n", + blurb(), blurb()); + if (p->verbose_p) { if (!si->uid_message || !*si->uid_message) @@ -1113,6 +1147,7 @@ maybe_reload_init_file (saver_info *si) sync_server_dpms_settings (si->dpy, (p->dpms_enabled_p && p->mode != DONT_BLANK), + p->dpms_quickoff_p, p->dpms_standby / 1000, p->dpms_suspend / 1000, p->dpms_off / 1000, @@ -1245,19 +1280,16 @@ main_loop (saver_info *si) for (i = 0; i < si->nscreens; i++) spawn_screenhack (&si->screens[i]); - /* If we are blanking only, optionally power down monitor right now. - To do this, we might need to temporarily re-enable DPMS first. - */ + /* If we are blanking only, optionally power down monitor right now. */ if (p->mode == BLANK_ONLY && p->dpms_enabled_p && p->dpms_quickoff_p) { sync_server_dpms_settings (si->dpy, True, + p->dpms_quickoff_p, p->dpms_standby / 1000, p->dpms_suspend / 1000, - (p->dpms_off - ? (p->dpms_off / 1000) - : 0xFFFF), + p->dpms_off / 1000, False); monitor_power_on (si, False); } @@ -1503,7 +1535,7 @@ main (int argc, char **argv) if (p->verbose_p) analyze_display (si); initialize_server_extensions (si); - si->blank_time = time ((time_t) 0); /* must be before ..._window */ + si->blank_time = time ((time_t *) 0); /* must be before ..._window */ initialize_screensaver_window (si); select_events (si); @@ -1513,6 +1545,7 @@ main (int argc, char **argv) sync_server_dpms_settings (si->dpy, (p->dpms_enabled_p && p->mode != DONT_BLANK), + p->dpms_quickoff_p, p->dpms_standby / 1000, p->dpms_suspend / 1000, p->dpms_off / 1000, @@ -1777,29 +1810,47 @@ handle_clientmessage (saver_info *si, XEvent *event, Bool until_idle_p) } else if (type == XA_DEACTIVATE) { - if (! until_idle_p) - { - if (si->throttled_p && p->verbose_p) - fprintf (stderr, "%s: unthrottled.\n", blurb()); - si->throttled_p = False; +# if 0 + /* When -deactivate is received while locked, pop up the dialog box + instead of just ignoring it. Some people depend on this behavior + to be able to unlock by using e.g. a fingerprint reader without + also having to click the mouse first. + */ + if (si->locked_p) + { + clientmessage_response(si, window, False, + "DEACTIVATE ClientMessage received while locked: ignored.", + "screen is locked."); + } + else +# endif /* 0 */ + { + if (! until_idle_p) + { + if (si->throttled_p && p->verbose_p) + fprintf (stderr, "%s: unthrottled.\n", blurb()); + si->throttled_p = False; - clientmessage_response(si, window, False, - "DEACTIVATE ClientMessage received.", - "deactivating."); - if (si->using_mit_saver_extension || si->using_sgi_saver_extension) - { - XForceScreenSaver (si->dpy, ScreenSaverReset); - return False; - } - else - { - return True; - } - } - clientmessage_response(si, window, False, - "ClientMessage DEACTIVATE received while inactive: resetting idle timer.", - "not active: idle timer reset."); - reset_timers (si); + clientmessage_response(si, window, False, + "DEACTIVATE ClientMessage received.", + "deactivating."); + if (si->using_mit_saver_extension || + si->using_sgi_saver_extension) + { + XForceScreenSaver (si->dpy, ScreenSaverReset); + return False; + } + else + { + return True; + } + } + clientmessage_response(si, window, False, + "ClientMessage DEACTIVATE received while inactive: " + "resetting idle timer.", + "not active: idle timer reset."); + reset_timers (si); + } } else if (type == XA_CYCLE) { @@ -2288,11 +2339,13 @@ analyze_display (saver_info *si) vi_in.screen = ssi->real_screen_number; vi_out = XGetVisualInfo (si->dpy, VisualScreenMask, &vi_in, &out_count); if (!vi_out) continue; - for (j = 0; j < out_count; j++) + for (j = 0; j < out_count; j++) { + if (vi_out[j].depth >= 32) continue; if (vi_out[j].class == PseudoColor) colormapped_depths |= (1 << vi_out[j].depth); else non_mapped_depths |= (1 << vi_out[j].depth); + } XFree ((char *) vi_out); if (colormapped_depths)