http://www.jwz.org/xscreensaver/xscreensaver-5.13.tar.gz
[xscreensaver] / driver / xscreensaver.c
index 1ac1d68c16da2ae8312631958807dd83b0c475a4..2fdc4ac6d20b5a04ae6ff66f14ec8cedf854274a 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1991-2008 Jamie Zawinski <jwz@jwz.org>
+/* xscreensaver, Copyright (c) 1991-2011 Jamie Zawinski <jwz@jwz.org>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
 #include <ctype.h>
 #include <X11/Xlib.h>
 
+#ifdef ENABLE_NLS
+# include <locale.h>
+# include <libintl.h>
+#endif /* ENABLE_NLS */
+
 #include <X11/Xlibint.h>
 
 #include <X11/Xatom.h>
@@ -574,6 +579,9 @@ lock_initialization (saver_info *si, int *argc, char **argv)
         }
     }
 
+  if (si->prefs.debug_p)    /* But allow locking anyway in debug mode. */
+    si->locking_disabled_p = False;
+
 #endif /* NO_LOCKING */
 }
 
@@ -857,12 +865,14 @@ initialize_server_extensions (saver_info *si)
   Bool server_has_sgi_saver_extension_p = False;
   Bool server_has_mit_saver_extension_p = False;
   Bool system_has_proc_interrupts_p = False;
+  Bool server_has_xinput_extension_p = False;
   const char *piwhy = 0;
 
   si->using_xidle_extension = p->use_xidle_extension;
   si->using_sgi_saver_extension = p->use_sgi_saver_extension;
   si->using_mit_saver_extension = p->use_mit_saver_extension;
   si->using_proc_interrupts = p->use_proc_interrupts;
+  si->using_xinput_extension = p->use_xinput_extension;
 
 #ifdef HAVE_XIDLE_EXTENSION
   {
@@ -886,6 +896,10 @@ initialize_server_extensions (saver_info *si)
   system_has_proc_interrupts_p = query_proc_interrupts_available (si, &piwhy);
 #endif
 
+#ifdef HAVE_XINPUT
+  server_has_xinput_extension_p = query_xinput_extension (si);
+#endif
+
   if (!server_has_xidle_extension_p)
     si->using_xidle_extension = False;
   else if (p->verbose_p)
@@ -928,6 +942,8 @@ initialize_server_extensions (saver_info *si)
       int nscreens = ScreenCount (si->dpy);  /* number of *real* screens */
       int i;
 
+      si->using_randr_extension = TRUE;
+
       if (p->verbose_p)
        fprintf (stderr, "%s: selecting RANDR events\n", blurb());
       for (i = 0; i < nscreens; i++)
@@ -940,6 +956,28 @@ initialize_server_extensions (saver_info *si)
     }
 # endif /* HAVE_RANDR */
 
+#ifdef HAVE_XINPUT
+  if (!server_has_xinput_extension_p)
+    si->using_xinput_extension = False;
+  else
+    {
+      if (si->using_xinput_extension)
+        init_xinput_extension(si);
+
+      if (p->verbose_p)
+        {
+          if (si->using_xinput_extension)
+            fprintf (stderr,
+                     "%s: selecting events from %d XInputExtension devices.\n",
+                     blurb(), si->num_xinput_devices);
+          else
+            fprintf (stderr,
+                     "%s: not using XInputExtension.\n",
+                     blurb());
+        }
+    }
+#endif
+
   if (!system_has_proc_interrupts_p)
     {
       si->using_proc_interrupts = False;
@@ -1189,6 +1227,11 @@ main_loop (saver_info *si)
         for (i = 0; i < si->nscreens; i++)
           spawn_screenhack (&si->screens[i]);
 
+      /* If we are blanking only, we might as well power down the monitor
+         right now, regardless of what the DPMS settings are. */
+      if (p->mode == BLANK_ONLY)
+        monitor_power_on (si, False);
+
       /* Don't start the cycle timer in demo mode. */
       if (!si->demoing_p && p->cycle)
        si->cycle_id = XtAppAddTimeOut (si->app,
@@ -1344,6 +1387,23 @@ main (int argc, char **argv)
   struct passwd *spasswd;
   int i;
 
+  /* It turns out that if we do NLS stuff here, people running in Japanese
+     locales get font craziness on the password dialog, presumably because
+     it is displaying Japanese characters in a non-Japanese font.  I don't
+     understand how to automatically make all this crap work properly by
+     default, so until someone sends me a better patch, just leave it off
+     and run the daemon in English.  -- jwz, 29-Sep-2010
+   */
+#undef ENABLE_NLS
+
+#ifdef ENABLE_NLS
+  if (!setlocale (LC_ALL, ""))
+    fprintf (stderr, "locale not supported by C library\n");
+
+  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+  textdomain (GETTEXT_PACKAGE);
+#endif /* ENABLE_NLS */
+
   memset(si, 0, sizeof(*si));
   global_si_kludge = si;       /* I hate C so much... */
 
@@ -2124,8 +2184,14 @@ analyze_display (saver_info *si)
 #     endif
    }, { "DRI",                                 "DRI",
         True,  0
+   }, { "NV-CONTROL",                           "NVidia",
+        True,  0
+   }, { "NV-GLX",                               "NVidia GLX",
+        True,  0
    }, { "Apple-DRI",                            "Apple-DRI (XDarwin)",
         True,  0
+   }, { "XInputExtension",                      "XInput",
+        True,  0
    },
   };