http://ftp.x.org/contrib/applications/xscreensaver-3.01.tar.gz
authorZygo Blaxell <zblaxell@hungrycats.org>
Mon, 2 Mar 2009 05:42:29 +0000 (00:42 -0500)
committerZygo Blaxell <zblaxell@hungrycats.org>
Mon, 2 Mar 2009 05:42:29 +0000 (00:42 -0500)
-rw-r--r-- 1 zblaxell zblaxell 957208 Oct 23  1998 xscreensaver-3.01.tar.gz
80e173a3c061adfeb076f24815b6019910a5bfee  xscreensaver-3.01.tar.gz

37 files changed:
Makefile.in
README
README.debugging
config.h.in
configure
configure.in
driver/Makefile.in
driver/XScreenSaver.ad.in
driver/XScreenSaver_ad.h
driver/demo.c
driver/dialogs-Xaw.c
driver/dialogs-Xm.c
driver/dotfile.c [deleted file]
driver/lock.c
driver/prefs.c [new file with mode: 0644]
driver/prefs.h [new file with mode: 0644]
driver/remote.c [new file with mode: 0644]
driver/remote.h [new file with mode: 0644]
driver/setuid.c
driver/splash.c
driver/subprocs.c
driver/test-passwd.c
driver/timers.c
driver/windows.c
driver/xscreensaver-command.c
driver/xscreensaver-command.man
driver/xscreensaver-demo.man [new file with mode: 0644]
driver/xscreensaver.c
driver/xscreensaver.h
driver/xscreensaver.man
driver/xset.c
hacks/bsod.c
hacks/distort.c
hacks/images/atari.xbm
utils/version.h
xscreensaver.lsm
xscreensaver.lsm.sh

index 89d3a43b9f829058d2e205c0674d15350a406115..266f4db116cba152237e967ed11f0da07a04a9de 100644 (file)
@@ -127,6 +127,7 @@ bump-version::
   set - $$VERS ;                                                           \
   MAJOR="$$1"; MINOR="$$2";                                                \
   NEW=`echo $$MINOR + 1 | bc` ;                                                    \
+  NEW=`echo $$NEW | sed 's/^\([0-9]\)$$/0\1/'` ;                           \
   D=`date '+%d-%b-%y'`;                                                            \
   if [ ! -f xscreensaver-$$MAJOR.$$MINOR.tar.gz ]; then                            \
     echo "WARNING: xscreensaver-$$MAJOR.$$MINOR.tar.gz does not exist.";    \
@@ -193,6 +194,7 @@ test-tar::
     echo --------------------------------------------------------------- ;  \
     ( cd utils; gmake ) ;                                                  \
     ( cd driver; gmake ) ;                                                 \
+    ( cd driver; gmake xscreensaver-demo-Xaw ) ;                           \
     echo --------------------------------------------------------------- ); \
                                                                            \
   ( cd BIN/lesstif ;                                                       \
@@ -202,9 +204,10 @@ test-tar::
     echo --------------------------------------------------------------- ;  \
     ( cd utils; gmake ) ;                                                  \
     ( cd driver; gmake ) ;                                                 \
+    ( cd driver; gmake xscreensaver-demo-Xaw ) ;                           \
     echo --------------------------------------------------------------- ); \
                                                                            \
-  chmod -R u+w . ;                                                         \
+  chmod -R u+w .
 
 
 www::
@@ -251,6 +254,7 @@ www::
                                                                            \
   (cd ..; $(MAKE) xscreensaver/changelog.html );                           \
   cvs diff -u0 changelog.html ;                                                    \
+  set +x ;                                                                 \
                                                                            \
   echo -n "Ok? ";                                                          \
   read line;                                                               \
diff --git a/README b/README
index 5d64fc62cdb9bb40865823c6e549cc0ac43c766e..acd0497a5d1b364593b56fe32ef9c9fcd4e8ca46 100644 (file)
--- a/README
+++ b/README
@@ -24,6 +24,10 @@ The most important hint is probably this:
 
 To build on VMS, see README.VMS.
 
+If you are upgrading, you might want to delete your ~/.xscreensaver file.
+If you don't, you might not see the new graphics modes.  If you are upgrading
+from version 2.* to version 3.*, definitely do delete your .xscreensaver file.
+
 If you think you've found a bug, please let me know!  No bug report is too
 small.  But first, please read the enclosed `README.debugging' file to find
 out what kind of information would be most helpful to include in your bug
@@ -73,6 +77,32 @@ http://www.jwz.org/xscreensaver/.
 
                               ============
 
+Changes since 3.00:   * Some fixes to `reflect'.
+                     * Configure tweaks.
+                     * Made it log unsuccessful attempts to unlock the screen
+                       to syslog.
+                     * Fixed a bug where `xscreensaver-demo' could be seeing
+                       a different programs list than `xscreensaver' did.
+Changes since 2.34:   * The xscreensaver daemon no longer links against Motif
+                       or Athena: demo-mode and the preferences panel are no
+                       longer built in to the daemon, but are now handled by
+                       an external program, `xscreensaver-demo'.
+                       (I decided that this, along with the recent addition
+                       of the `.xscreensaver' config file, justified bumping
+                       the version number to 3.00, since this is a fairly
+                       major architectural change.)
+                     * Lines in the `*programs' resource may now begin with
+                       the character "-", meaning "don't run this hack."
+                       In this way, it's possible to disable a hack without
+                       throwing away the information about it (making it 
+                       easier to change your mind later.)  Eventually the
+                       preferences/demo mode GUI should represent this as a
+                       checkbox or something.
+                     * Fixed a short race condition where it was possible for
+                       xscreensaver to die with a BadWindow error if it was
+                       blanking the screen just as another window was being
+                       deleted.
+                     * Made it possible to disable specific modes in `bsod'.
 Changes since 2.33:   * Fixed a bug that was making `pipes' generate way too
                        many valves.  Made the viewpoint in `pipes' be selected
                        randomly instead of always being -10 degrees.
index f5ca66eb5b38d374a8d7158965f3d97699911a84..31364dbffbc354c330ba5ca1ae4fe63943d0a6c5 100644 (file)
@@ -78,18 +78,15 @@ RUN-TIME PROBLEMS:
         *  What platform are you running on?  What does the included
            `./config.guess' shell script print?
 
-        *  Is the problem in the driver, or in the graphics hacks?
+        *  Is the problem in the driver (`xscreensaver'), the GUI
+           (`xscreensaver-demo'), or in the graphics hacks?
 
-        *  If the problem is in the driver, was the driver built using
+        *  If the problem is in the GUI, was the it built using
            Motif, Lesstif, or Athena?  Which version?
 
         *  If the problem is in one (or more) of the hacks, which ones?
-           If you're not sure, try
-
-              xscreensaver-command -demo
-
-           to go through the list of them and see which work and which
-           don't.
+           If you're not sure, try running `xscreensaver-demo' to go
+           through the list of them and see which work and which don't.
 
         *  Does the problem occur when running that hack by hand, in
            its own window (i.e., when started with no command-line args)?
@@ -138,12 +135,12 @@ RUN-TIME PROBLEMS:
 
         *  Start `xscreensaver' with the command-line arguments
 
-              -verbose -no-capture-stderr
+              -verbose -no-capture
 
            This will cause it to write a lot of debugging info to the stderr
            of the xscreensaver process (the `-verbose' option turns on the
-           diagnostics; the `-no-capture-stderr' option prevents the data
-           from being displayed on the screensaver window as well.)
+           diagnostics; the `-no-capture' option prevents the data from being
+           displayed on the screensaver window as well.)
 
            You also might want to use the `-timestamp' option, which will
            cause the xscreensaver messages to include the time at which
@@ -154,7 +151,7 @@ RUN-TIME PROBLEMS:
            you could start it from your login script like this (csh syntax):
 
               ( cd ~/src/xscreensaver/ ; \
-                xscreensaver -sync -verbose -timestamp -no-capture-stderr \
+                xscreensaver -sync -verbose -timestamp -no-capture \
                 >>&LOG & )
 
         *  Hackers only: If you're feeling adventurous enough to run gdb
index b0121fd2b069c1c683d6d9f1e299fc9326b60730..98424f9b51df116a60ba26c39b9b82262b87bb92 100644 (file)
 #undef HAVE_VT_LOCKSWITCH
 
 
+/* Define this if you the openlog(), syslog(), and closelog() functions.
+   This is used for logging failed login attempts.
+ */
+#undef HAVE_SYSLOG
+
+
 /* *************************************************************************
                             OTHER C ENVIRONMENT JUNK
    ************************************************************************* */
index 73a1ef5f0f25fdbca97f7e0294eb519e88f81cac..c340a6797fb9df55181a9f33fee0d629eda80503 100755 (executable)
--- a/configure
+++ b/configure
@@ -616,6 +616,11 @@ fi
 
 
 
+echo -n "current directory: "
+pwd
+echo "command line was: $0 $@"
+
+
 ac_aux_dir=
 for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
   if test -f $ac_dir/install-sh; then
@@ -642,7 +647,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
 fi
 
 echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:657: checking host system type" >&5
+echo "configure:662: checking host system type" >&5
 
 host_alias=$host
 case "$host_alias" in
@@ -666,7 +671,7 @@ echo "$ac_t""$host" 1>&6
 # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:681: checking for $ac_word" >&5
+echo "configure:686: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -695,7 +700,7 @@ if test -z "$CC"; then
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:710: checking for $ac_word" >&5
+echo "configure:715: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -743,7 +748,7 @@ fi
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:758: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:763: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
 
 ac_ext=c
 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
@@ -753,11 +758,11 @@ ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS
 cross_compiling=$ac_cv_prog_cc_cross
 
 cat > conftest.$ac_ext <<EOF
-#line 768 "configure"
+#line 773 "configure"
 #include "confdefs.h"
 main(){return(0);}
 EOF
-if { (eval echo configure:772: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:777: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   ac_cv_prog_cc_works=yes
   # If we can't run a trivial program, we are probably using a cross compiler.
   if (./conftest; exit) 2>/dev/null; then
@@ -777,12 +782,12 @@ if test $ac_cv_prog_cc_works = no; then
   { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:792: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:797: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
 cross_compiling=$ac_cv_prog_cc_cross
 
 echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:797: checking whether we are using GNU C" >&5
+echo "configure:802: checking whether we are using GNU C" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -791,7 +796,7 @@ else
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:806: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:811: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   ac_cv_prog_gcc=yes
 else
   ac_cv_prog_gcc=no
@@ -806,7 +811,7 @@ if test $ac_cv_prog_gcc = yes; then
   ac_save_CFLAGS="$CFLAGS"
   CFLAGS=
   echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:821: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:826: checking whether ${CC-cc} accepts -g" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -836,7 +841,7 @@ fi
 
 if test -z "$GCC"; then
   echo $ac_n "checking how to request ANSI compilation""... $ac_c" 1>&6
-echo "configure:851: checking how to request ANSI compilation" >&5
+echo "configure:856: checking how to request ANSI compilation" >&5
   case "$host" in
     *-hpux*)
       echo "$ac_t""HPUX: adding -Ae" 1>&6
@@ -860,16 +865,16 @@ fi
 
 
 echo $ac_n "checking whether the compiler works on ANSI C""... $ac_c" 1>&6
-echo "configure:875: checking whether the compiler works on ANSI C" >&5
+echo "configure:880: checking whether the compiler works on ANSI C" >&5
 if test "$cross_compiling" = yes; then
   { echo "configure: error: Couldn't build even a trivial ANSI C program: check CC." 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 880 "configure"
+#line 885 "configure"
 #include "confdefs.h"
  main(int ac, char **av) { return 0; } 
 EOF
-if { (eval echo configure:884: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:889: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   echo "$ac_t""yes" 1>&6
 else
@@ -918,7 +923,7 @@ esac
 
 
 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:933: checking how to run the C preprocessor" >&5
+echo "configure:938: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -933,13 +938,13 @@ else
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 948 "configure"
+#line 953 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:954: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:959: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   :
@@ -950,13 +955,13 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 965 "configure"
+#line 970 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:971: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:976: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   :
@@ -989,7 +994,7 @@ echo "$ac_t""$CPP" 1>&6
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
 echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:1004: checking for a BSD compatible install" >&5
+echo "configure:1009: checking for a BSD compatible install" >&5
 if test -z "$INSTALL"; then
 if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1040,7 +1045,7 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 
 INSTALL_DIRS='${INSTALL} -d'
    echo $ac_n "checking whether \"\${INSTALL} -d\" creates intermediate directories""... $ac_c" 1>&6
-echo "configure:1055: checking whether \"\${INSTALL} -d\" creates intermediate directories" >&5
+echo "configure:1060: checking whether \"\${INSTALL} -d\" creates intermediate directories" >&5
    rm -rf conftestdir
    if mkdir conftestdir; then
       cd conftestdir >&-
@@ -1051,7 +1056,7 @@ echo "configure:1055: checking whether \"\${INSTALL} -d\" creates intermediate d
       else
         echo "$ac_t""no" 1>&6
         echo $ac_n "checking whether \"mkdir -p\" creates intermediate directories""... $ac_c" 1>&6
-echo "configure:1066: checking whether \"mkdir -p\" creates intermediate directories" >&5
+echo "configure:1071: checking whether \"mkdir -p\" creates intermediate directories" >&5
         rm -rf dir1
         mkdir -p dir1/dir2 >&- 2>&-
         if test -d dir1/dir2/. ; then
@@ -1066,7 +1071,7 @@ echo "configure:1066: checking whether \"mkdir -p\" creates intermediate directo
    fi
 
 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:1081: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:1086: checking whether ${MAKE-make} sets \${MAKE}" >&5
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1094,12 +1099,12 @@ fi
 
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:1109: checking for working const" >&5
+echo "configure:1114: checking for working const" >&5
 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1114 "configure"
+#line 1119 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -1148,7 +1153,7 @@ ccp = (char const *const *) p;
 
 ; return 0; }
 EOF
-if { (eval echo configure:1163: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1168: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -1169,21 +1174,21 @@ EOF
 fi
 
 echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:1184: checking for inline" >&5
+echo "configure:1189: checking for inline" >&5
 if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_cv_c_inline=no
 for ac_kw in inline __inline__ __inline; do
   cat > conftest.$ac_ext <<EOF
-#line 1191 "configure"
+#line 1196 "configure"
 #include "confdefs.h"
 
 int main() {
 } $ac_kw foo() {
 ; return 0; }
 EOF
-if { (eval echo configure:1198: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1203: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_inline=$ac_kw; break
 else
@@ -1210,12 +1215,12 @@ esac
 
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1225: checking for ANSI C header files" >&5
+echo "configure:1230: checking for ANSI C header files" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1230 "configure"
+#line 1235 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -1223,7 +1228,7 @@ else
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1238: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1243: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1240,7 +1245,7 @@ rm -f conftest*
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 1255 "configure"
+#line 1260 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -1258,7 +1263,7 @@ fi
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 1273 "configure"
+#line 1278 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -1279,7 +1284,7 @@ if test "$cross_compiling" = yes; then
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 1294 "configure"
+#line 1299 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -1290,7 +1295,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
 exit (0); }
 
 EOF
-if { (eval echo configure:1305: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1310: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -1314,12 +1319,12 @@ EOF
 fi
 
 echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:1329: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:1334: checking whether time.h and sys/time.h may both be included" >&5
 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1334 "configure"
+#line 1339 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -1328,7 +1333,7 @@ int main() {
 struct tm *tp;
 ; return 0; }
 EOF
-if { (eval echo configure:1343: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1348: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
 else
@@ -1349,12 +1354,12 @@ EOF
 fi
 
 echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
-echo "configure:1364: checking for sys/wait.h that is POSIX.1 compatible" >&5
+echo "configure:1369: checking for sys/wait.h that is POSIX.1 compatible" >&5
 if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1369 "configure"
+#line 1374 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/wait.h>
@@ -1370,7 +1375,7 @@ wait (&s);
 s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
 ; return 0; }
 EOF
-if { (eval echo configure:1385: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1390: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_sys_wait_h=yes
 else
@@ -1395,12 +1400,12 @@ for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6
-echo "configure:1410: checking for $ac_hdr that defines DIR" >&5
+echo "configure:1415: checking for $ac_hdr that defines DIR" >&5
 if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1415 "configure"
+#line 1420 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <$ac_hdr>
@@ -1408,7 +1413,7 @@ int main() {
 DIR *dirp = 0;
 ; return 0; }
 EOF
-if { (eval echo configure:1423: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1428: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   eval "ac_cv_header_dirent_$ac_safe=yes"
 else
@@ -1433,7 +1438,7 @@ done
 # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
 if test $ac_header_dirent = dirent.h; then
 echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6
-echo "configure:1448: checking for opendir in -ldir" >&5
+echo "configure:1453: checking for opendir in -ldir" >&5
 ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1441,7 +1446,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldir  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1456 "configure"
+#line 1461 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1452,7 +1457,7 @@ int main() {
 opendir()
 ; return 0; }
 EOF
-if { (eval echo configure:1467: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1472: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1474,7 +1479,7 @@ fi
 
 else
 echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
-echo "configure:1489: checking for opendir in -lx" >&5
+echo "configure:1494: checking for opendir in -lx" >&5
 ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1482,7 +1487,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lx  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1497 "configure"
+#line 1502 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1493,7 +1498,7 @@ int main() {
 opendir()
 ; return 0; }
 EOF
-if { (eval echo configure:1508: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1513: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1517,12 +1522,12 @@ fi
 
 
 echo $ac_n "checking for mode_t""... $ac_c" 1>&6
-echo "configure:1532: checking for mode_t" >&5
+echo "configure:1537: checking for mode_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_mode_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1537 "configure"
+#line 1542 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -1550,12 +1555,12 @@ EOF
 fi
 
 echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:1565: checking for pid_t" >&5
+echo "configure:1570: checking for pid_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1570 "configure"
+#line 1575 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -1583,12 +1588,12 @@ EOF
 fi
 
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:1598: checking for size_t" >&5
+echo "configure:1603: checking for size_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1603 "configure"
+#line 1608 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -1616,12 +1621,12 @@ EOF
 fi
 
 echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:1631: checking return type of signal handlers" >&5
+echo "configure:1636: checking return type of signal handlers" >&5
 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1636 "configure"
+#line 1641 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -1638,7 +1643,7 @@ int main() {
 int i;
 ; return 0; }
 EOF
-if { (eval echo configure:1653: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1658: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_type_signal=void
 else
@@ -1658,12 +1663,12 @@ EOF
 
 
 echo $ac_n "checking how to call gettimeofday""... $ac_c" 1>&6
-echo "configure:1673: checking how to call gettimeofday" >&5
+echo "configure:1678: checking how to call gettimeofday" >&5
 if eval "test \"`echo '$''{'ac_cv_gettimeofday_args'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1678 "configure"
+#line 1683 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
                  #include <sys/time.h>
@@ -1672,7 +1677,7 @@ struct timeval tv; struct timezone tzp;
                  gettimeofday(&tv, &tzp);
 ; return 0; }
 EOF
-if { (eval echo configure:1687: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1692: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_gettimeofday_args=2
 else
@@ -1680,7 +1685,7 @@ else
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   cat > conftest.$ac_ext <<EOF
-#line 1695 "configure"
+#line 1700 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
                                  #include <sys/time.h>
@@ -1688,7 +1693,7 @@ int main() {
 struct timeval tv; gettimeofday(&tv);
 ; return 0; }
 EOF
-if { (eval echo configure:1703: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1708: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_gettimeofday_args=1
 else
@@ -1704,13 +1709,13 @@ rm -f conftest*
 fi
 
 ac_gettimeofday_args=$ac_cv_gettimeofday_args
-if test $ac_gettimeofday_args = 1 ; then
+if test "$ac_gettimeofday_args" = 1 ; then
   cat >> confdefs.h <<\EOF
 #define HAVE_GETTIMEOFDAY 1
 EOF
 
   echo "$ac_t""one argument" 1>&6
-elif test $ac_gettimeofday_args = 2 ; then
+elif test "$ac_gettimeofday_args" = 2 ; then
   cat >> confdefs.h <<\EOF
 #define HAVE_GETTIMEOFDAY 1
 EOF
@@ -1728,12 +1733,12 @@ fi
 for ac_func in select fcntl uname nice setpriority getcwd getwd putenv
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1743: checking for $ac_func" >&5
+echo "configure:1748: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1748 "configure"
+#line 1753 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -1756,7 +1761,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:1771: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1776: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -1780,15 +1785,15 @@ else
 fi
 done
 
-for ac_func in sigaction
+for ac_func in sigaction syslog
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1798: checking for $ac_func" >&5
+echo "configure:1803: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1803 "configure"
+#line 1808 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -1811,7 +1816,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:1826: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1831: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -1840,17 +1845,17 @@ for ac_hdr in unistd.h crypt.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1855: checking for $ac_hdr" >&5
+echo "configure:1860: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1860 "configure"
+#line 1865 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1865: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1870: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1909,7 +1914,7 @@ fi
 # Uses ac_ vars as temps to allow command line to override cache and checks.
 # --without-x overrides everything else, but does not touch the cache.
 echo $ac_n "checking for X""... $ac_c" 1>&6
-echo "configure:1924: checking for X" >&5
+echo "configure:1929: checking for X" >&5
 
 # Check whether --with-x or --without-x was given.
 if test "${with_x+set}" = set; then
@@ -1971,12 +1976,12 @@ if test "$ac_x_includes" = NO; then
 
   # First, try using that file with no special directory specified.
 cat > conftest.$ac_ext <<EOF
-#line 1986 "configure"
+#line 1991 "configure"
 #include "confdefs.h"
 #include <$x_direct_test_include>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1991: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1996: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2045,14 +2050,14 @@ if test "$ac_x_libraries" = NO; then
   ac_save_LIBS="$LIBS"
   LIBS="-l$x_direct_test_library $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2060 "configure"
+#line 2065 "configure"
 #include "confdefs.h"
 
 int main() {
 ${x_direct_test_function}()
 ; return 0; }
 EOF
-if { (eval echo configure:2067: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2072: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   LIBS="$ac_save_LIBS"
 # We can link X programs with no special library path.
@@ -2158,17 +2163,17 @@ else
     case "`(uname -sr) 2>/dev/null`" in
     "SunOS 5"*)
       echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6
-echo "configure:2173: checking whether -R must be followed by a space" >&5
+echo "configure:2178: checking whether -R must be followed by a space" >&5
       ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries"
       cat > conftest.$ac_ext <<EOF
-#line 2176 "configure"
+#line 2181 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:2183: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2188: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_R_nospace=yes
 else
@@ -2184,14 +2189,14 @@ rm -f conftest*
       else
        LIBS="$ac_xsave_LIBS -R $x_libraries"
        cat > conftest.$ac_ext <<EOF
-#line 2199 "configure"
+#line 2204 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:2206: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2211: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_R_space=yes
 else
@@ -2223,7 +2228,7 @@ rm -f conftest*
     # libraries were built with DECnet support.  And karl@cs.umb.edu says
     # the Alpha needs dnet_stub (dnet does not exist).
     echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6
-echo "configure:2238: checking for dnet_ntoa in -ldnet" >&5
+echo "configure:2243: checking for dnet_ntoa in -ldnet" >&5
 ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2231,7 +2236,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2246 "configure"
+#line 2251 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2242,7 +2247,7 @@ int main() {
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:2257: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2262: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2264,7 +2269,7 @@ fi
 
     if test $ac_cv_lib_dnet_dnet_ntoa = no; then
       echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6
-echo "configure:2279: checking for dnet_ntoa in -ldnet_stub" >&5
+echo "configure:2284: checking for dnet_ntoa in -ldnet_stub" >&5
 ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2272,7 +2277,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet_stub  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2287 "configure"
+#line 2292 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2283,7 +2288,7 @@ int main() {
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:2298: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2303: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2312,12 +2317,12 @@ fi
     # The nsl library prevents programs from opening the X display
     # on Irix 5.2, according to dickey@clark.net.
     echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6
-echo "configure:2327: checking for gethostbyname" >&5
+echo "configure:2332: checking for gethostbyname" >&5
 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2332 "configure"
+#line 2337 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gethostbyname(); below.  */
@@ -2340,7 +2345,7 @@ gethostbyname();
 
 ; return 0; }
 EOF
-if { (eval echo configure:2355: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2360: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_gethostbyname=yes"
 else
@@ -2361,7 +2366,7 @@ fi
 
     if test $ac_cv_func_gethostbyname = no; then
       echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
-echo "configure:2376: checking for gethostbyname in -lnsl" >&5
+echo "configure:2381: checking for gethostbyname in -lnsl" >&5
 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2369,7 +2374,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2384 "configure"
+#line 2389 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2380,7 +2385,7 @@ int main() {
 gethostbyname()
 ; return 0; }
 EOF
-if { (eval echo configure:2395: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2400: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2410,12 +2415,12 @@ fi
     # -lsocket must be given before -lnsl if both are needed.
     # We assume that if connect needs -lnsl, so does gethostbyname.
     echo $ac_n "checking for connect""... $ac_c" 1>&6
-echo "configure:2425: checking for connect" >&5
+echo "configure:2430: checking for connect" >&5
 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2430 "configure"
+#line 2435 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char connect(); below.  */
@@ -2438,7 +2443,7 @@ connect();
 
 ; return 0; }
 EOF
-if { (eval echo configure:2453: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2458: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_connect=yes"
 else
@@ -2459,7 +2464,7 @@ fi
 
     if test $ac_cv_func_connect = no; then
       echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6
-echo "configure:2474: checking for connect in -lsocket" >&5
+echo "configure:2479: checking for connect in -lsocket" >&5
 ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2467,7 +2472,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2482 "configure"
+#line 2487 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2478,7 +2483,7 @@ int main() {
 connect()
 ; return 0; }
 EOF
-if { (eval echo configure:2493: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2498: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2502,12 +2507,12 @@ fi
 
     # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX.
     echo $ac_n "checking for remove""... $ac_c" 1>&6
-echo "configure:2517: checking for remove" >&5
+echo "configure:2522: checking for remove" >&5
 if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2522 "configure"
+#line 2527 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char remove(); below.  */
@@ -2530,7 +2535,7 @@ remove();
 
 ; return 0; }
 EOF
-if { (eval echo configure:2545: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2550: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_remove=yes"
 else
@@ -2551,7 +2556,7 @@ fi
 
     if test $ac_cv_func_remove = no; then
       echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6
-echo "configure:2566: checking for remove in -lposix" >&5
+echo "configure:2571: checking for remove in -lposix" >&5
 ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2559,7 +2564,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lposix  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2574 "configure"
+#line 2579 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2570,7 +2575,7 @@ int main() {
 remove()
 ; return 0; }
 EOF
-if { (eval echo configure:2585: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2590: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2594,12 +2599,12 @@ fi
 
     # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
     echo $ac_n "checking for shmat""... $ac_c" 1>&6
-echo "configure:2609: checking for shmat" >&5
+echo "configure:2614: checking for shmat" >&5
 if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2614 "configure"
+#line 2619 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char shmat(); below.  */
@@ -2622,7 +2627,7 @@ shmat();
 
 ; return 0; }
 EOF
-if { (eval echo configure:2637: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2642: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_shmat=yes"
 else
@@ -2643,7 +2648,7 @@ fi
 
     if test $ac_cv_func_shmat = no; then
       echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6
-echo "configure:2658: checking for shmat in -lipc" >&5
+echo "configure:2663: checking for shmat in -lipc" >&5
 ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2651,7 +2656,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lipc  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2666 "configure"
+#line 2671 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2662,7 +2667,7 @@ int main() {
 shmat()
 ; return 0; }
 EOF
-if { (eval echo configure:2677: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2682: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2695,7 +2700,7 @@ fi
   # libraries we check for below, so use a different variable.
   #  --interran@uluru.Stanford.EDU, kb@cs.umb.edu.
   echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6
-echo "configure:2710: checking for IceConnectionNumber in -lICE" >&5
+echo "configure:2715: checking for IceConnectionNumber in -lICE" >&5
 ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2703,7 +2708,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lICE  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2718 "configure"
+#line 2723 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2714,7 +2719,7 @@ int main() {
 IceConnectionNumber()
 ; return 0; }
 EOF
-if { (eval echo configure:2729: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2734: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2751,7 +2756,7 @@ fi
 
 
     echo $ac_n "checking for X app-defaults directory""... $ac_c" 1>&6
-echo "configure:2766: checking for X app-defaults directory" >&5
+echo "configure:2771: checking for X app-defaults directory" >&5
 if eval "test \"`echo '$''{'ac_cv_x_app_defaults'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2898,7 +2903,7 @@ APPDEFAULTS=$ac_x_app_defaults
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 2913 "configure"
+#line 2918 "configure"
 #include "confdefs.h"
 #include <X11/XHPlib.h>
 EOF
@@ -2919,7 +2924,7 @@ rm -f conftest*
 # Check for the availability of the XPointer typedef, and define it otherwise.
 #
 echo $ac_n "checking for XPointer""... $ac_c" 1>&6
-echo "configure:2934: checking for XPointer" >&5
+echo "configure:2939: checking for XPointer" >&5
 if eval "test \"`echo '$''{'ac_cv_xpointer'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2930,14 +2935,14 @@ else
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 2945 "configure"
+#line 2950 "configure"
 #include "confdefs.h"
 #include <X11/Xlib.h>
 int main() {
 XPointer foo = (XPointer) 0;
 ; return 0; }
 EOF
-if { (eval echo configure:2952: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2957: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_xpointer=yes
 else
@@ -2951,7 +2956,7 @@ rm -f conftest*
 fi
 
 echo "$ac_t""$ac_cv_xpointer" 1>&6
-if test $ac_cv_xpointer != yes; then
+if test "$ac_cv_xpointer" != yes; then
   cat >> confdefs.h <<\EOF
 #define XPointer char*
 EOF
@@ -3071,7 +3076,7 @@ case "$host" in
 
       # Some versions of Slowlaris Motif require -lgen.  But not all.  Why?
       echo $ac_n "checking for regcmp in -lgen""... $ac_c" 1>&6
-echo "configure:3086: checking for regcmp in -lgen" >&5
+echo "configure:3091: checking for regcmp in -lgen" >&5
 ac_lib_var=`echo gen'_'regcmp | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3079,7 +3084,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgen  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3094 "configure"
+#line 3099 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3090,7 +3095,7 @@ int main() {
 regcmp()
 ; return 0; }
 EOF
-if { (eval echo configure:3105: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3110: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3127,17 +3132,17 @@ have_xmu=no
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/Xmu/Error.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/Xmu/Error.h""... $ac_c" 1>&6
-echo "configure:3142: checking for X11/Xmu/Error.h" >&5
+echo "configure:3147: checking for X11/Xmu/Error.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3147 "configure"
+#line 3152 "configure"
 #include "confdefs.h"
 #include <X11/Xmu/Error.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3152: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3157: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3159,7 +3164,7 @@ else
 fi
 
   CPPFLAGS="$ac_save_CPPFLAGS"
-if test $have_xmu = no ; then
+if test "$have_xmu" = no ; then
   XMU_SRCS='$(UTILS_SRC)/xmu.c'
   XMU_OBJS='$(UTILS_BIN)/xmu.o'
 else
@@ -3177,11 +3182,11 @@ fi
 # See comp.windows.x FAQ question 124 about _get_wmShellWidgetClass on 4.1.x.
 # The right fix is to get OpenWindows 3.0 patches 100512-02 and 100573-03.
 #
-if test $have_xmu = yes ; then
+if test "$have_xmu" = yes ; then
   case "$host" in
     *-sunos4*)
     echo $ac_n "checking for the SunOS 4.1.x _get_wmShellWidgetClass bug""... $ac_c" 1>&6
-echo "configure:3196: checking for the SunOS 4.1.x _get_wmShellWidgetClass bug" >&5
+echo "configure:3201: checking for the SunOS 4.1.x _get_wmShellWidgetClass bug" >&5
 if eval "test \"`echo '$''{'ac_cv_sunos_xmu_bug'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3194,14 +3199,14 @@ else
                    # with X libraries because we know it's SunOS.
                    LDFLAGS="$LDFLAGS -lXmu -lXt -lX11 -lXext -lm"
                    cat > conftest.$ac_ext <<EOF
-#line 3209 "configure"
+#line 3214 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:3216: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3221: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_cv_sunos_xmu_bug=no
 else
@@ -3215,23 +3220,23 @@ rm -f conftest*
 fi
 
 echo "$ac_t""$ac_cv_sunos_xmu_bug" 1>&6
-    if test $ac_cv_sunos_xmu_bug = yes ; then
+    if test "$ac_cv_sunos_xmu_bug" = yes ; then
       echo $ac_n "checking whether the compiler understands -static""... $ac_c" 1>&6
-echo "configure:3232: checking whether the compiler understands -static" >&5
+echo "configure:3237: checking whether the compiler understands -static" >&5
 if eval "test \"`echo '$''{'ac_cv_ld_static'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LDFLAGS="$LDFLAGS"
                      LDFLAGS="$LDFLAGS -static"
                      cat > conftest.$ac_ext <<EOF
-#line 3239 "configure"
+#line 3244 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:3246: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3251: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_cv_ld_static=yes
 else
@@ -3245,7 +3250,7 @@ rm -f conftest*
 fi
 
 echo "$ac_t""$ac_cv_ld_static" 1>&6
-      if test $ac_cv_ld_static = yes ; then
+      if test "$ac_cv_ld_static" = yes ; then
         LDFLAGS="$LDFLAGS -static"
       else
        LDFLAGS="$LDFLAGS -Bstatic"
@@ -3276,7 +3281,7 @@ fi
 
     /*)
      echo $ac_n "checking for SGI SCREEN_SAVER headers""... $ac_c" 1>&6
-echo "configure:3291: checking for SGI SCREEN_SAVER headers" >&5
+echo "configure:3296: checking for SGI SCREEN_SAVER headers" >&5
      d=$with_sgi/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -3286,7 +3291,7 @@ echo "configure:3291: checking for SGI SCREEN_SAVER headers" >&5
      fi
 
      echo $ac_n "checking for SGI SCREEN_SAVER libs""... $ac_c" 1>&6
-echo "configure:3301: checking for SGI SCREEN_SAVER libs" >&5
+echo "configure:3306: checking for SGI SCREEN_SAVER libs" >&5
      d=$with_sgi/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -3315,7 +3320,7 @@ echo "configure:3301: checking for SGI SCREEN_SAVER libs" >&5
    withval=
   
 
-if test $with_sgi = yes; then
+if test "$with_sgi" = yes; then
   
   ac_save_CPPFLAGS="$CPPFLAGS"
   if test \! -z "$includedir" ; then 
@@ -3324,17 +3329,17 @@ if test $with_sgi = yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/extensions/XScreenSaver.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/extensions/XScreenSaver.h""... $ac_c" 1>&6
-echo "configure:3339: checking for X11/extensions/XScreenSaver.h" >&5
+echo "configure:3344: checking for X11/extensions/XScreenSaver.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3344 "configure"
+#line 3349 "configure"
 #include "confdefs.h"
 #include <X11/extensions/XScreenSaver.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3349: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3354: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3361,7 +3366,7 @@ fi
 
   CPPFLAGS="$ac_save_CPPFLAGS"
 
-elif test $with_sgi != no; then
+elif test "$with_sgi" != no; then
   echo "error: must be yes or no: --with-sgi-ext=$with_sgi"
   exit 1
 fi
@@ -3387,7 +3392,7 @@ fi
 
     /*)
      echo $ac_n "checking for MIT-SCREEN-SAVER headers""... $ac_c" 1>&6
-echo "configure:3402: checking for MIT-SCREEN-SAVER headers" >&5
+echo "configure:3407: checking for MIT-SCREEN-SAVER headers" >&5
      d=$with_mit/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -3397,7 +3402,7 @@ echo "configure:3402: checking for MIT-SCREEN-SAVER headers" >&5
      fi
 
      echo $ac_n "checking for MIT-SCREEN-SAVER libs""... $ac_c" 1>&6
-echo "configure:3412: checking for MIT-SCREEN-SAVER libs" >&5
+echo "configure:3417: checking for MIT-SCREEN-SAVER libs" >&5
      d=$with_mit/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -3426,8 +3431,8 @@ echo "configure:3412: checking for MIT-SCREEN-SAVER libs" >&5
    withval=
   
 
-if test $have_sgi != yes; then
-  if test $with_mit = yes; then
+if test "$have_sgi" != yes; then
+  if test "$with_mit" = yes; then
     
   ac_save_CPPFLAGS="$CPPFLAGS"
   if test \! -z "$includedir" ; then 
@@ -3436,17 +3441,17 @@ if test $have_sgi != yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/extensions/scrnsaver.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/extensions/scrnsaver.h""... $ac_c" 1>&6
-echo "configure:3451: checking for X11/extensions/scrnsaver.h" >&5
+echo "configure:3456: checking for X11/extensions/scrnsaver.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3456 "configure"
+#line 3461 "configure"
 #include "confdefs.h"
 #include <X11/extensions/scrnsaver.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3461: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3466: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3472,25 +3477,25 @@ fi
     # Now check to see if it's really in the library; XF86Free-3.3 ships
     # scrnsaver.h, but doesn't include the code in libXext.a, the idiots!
     #
-    if test $have_mit = yes; then
+    if test "$have_mit" = yes; then
       
   ac_save_CPPFLAGS="$CPPFLAGS"
   ac_save_LDFLAGS="$LDFLAGS"
+
   if test \! -z "$includedir" ; then 
     CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
-  if test \! -z "$includedir" ; then 
-    CPPFLAGS="$CPPFLAGS -I$includedir"
-  fi
+  # note: $X_CFLAGS includes $x_includes
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
   if test \! -z "$libdir" ; then
     LDFLAGS="$LDFLAGS -L$libdir"
   fi
-  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  if test \! -z "$x_libraries" ; then
-    LDFLAGS="$LDFLAGS -L$x_libraries"
-  fi
+  # note: $X_LIBS includes $x_libraries
+  LDFLAGS="$LDFLAGS $X_LIBS"
+
   echo $ac_n "checking for XScreenSaverRegister in -lXext""... $ac_c" 1>&6
-echo "configure:3505: checking for XScreenSaverRegister in -lXext" >&5
+echo "configure:3510: checking for XScreenSaverRegister in -lXext" >&5
 ac_lib_var=`echo Xext'_'XScreenSaverRegister | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3498,7 +3503,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lXext -lm $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3513 "configure"
+#line 3518 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3509,7 +3514,7 @@ int main() {
 XScreenSaverRegister()
 ; return 0; }
 EOF
-if { (eval echo configure:3524: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3529: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3540,27 +3545,27 @@ fi
   CPPFLAGS="$ac_save_CPPFLAGS"
   LDFLAGS="$ac_save_LDFLAGS"
 
-      if test $have_mit = no; then
+      if test "$have_mit" = no; then
        # Fuck!  Looks like XF86Free-3.3 actually puts it in XExExt instead
        # of in Xext.  Thank you master, may I have another.
         
   ac_save_CPPFLAGS="$CPPFLAGS"
   ac_save_LDFLAGS="$LDFLAGS"
+
   if test \! -z "$includedir" ; then 
     CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
-  if test \! -z "$includedir" ; then 
-    CPPFLAGS="$CPPFLAGS -I$includedir"
-  fi
+  # note: $X_CFLAGS includes $x_includes
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
   if test \! -z "$libdir" ; then
     LDFLAGS="$LDFLAGS -L$libdir"
   fi
-  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  if test \! -z "$x_libraries" ; then
-    LDFLAGS="$LDFLAGS -L$x_libraries"
-  fi
+  # note: $X_LIBS includes $x_libraries
+  LDFLAGS="$LDFLAGS $X_LIBS"
+
   echo $ac_n "checking for XScreenSaverRegister in -lXExExt""... $ac_c" 1>&6
-echo "configure:3575: checking for XScreenSaverRegister in -lXExExt" >&5
+echo "configure:3580: checking for XScreenSaverRegister in -lXExExt" >&5
 ac_lib_var=`echo XExExt'_'XScreenSaverRegister | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3568,7 +3573,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lXExExt -lX11 -lXext -lm $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3583 "configure"
+#line 3588 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3579,7 +3584,7 @@ int main() {
 XScreenSaverRegister()
 ; return 0; }
 EOF
-if { (eval echo configure:3594: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3599: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3603,7 +3608,7 @@ fi
   LDFLAGS="$ac_save_LDFLAGS"
       fi
 
-      if test $have_mit = no; then
+      if test "$have_mit" = no; then
        # Double fuck!  Looks like some versions of XFree86 (whichever version
        # it is that comes with RedHat Linux 2.0 -- I can't find a version 
        # number) put this garbage in Xss instead of Xext.  Thank you master,
@@ -3611,21 +3616,21 @@ fi
         
   ac_save_CPPFLAGS="$CPPFLAGS"
   ac_save_LDFLAGS="$LDFLAGS"
+
   if test \! -z "$includedir" ; then 
     CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
-  if test \! -z "$includedir" ; then 
-    CPPFLAGS="$CPPFLAGS -I$includedir"
-  fi
+  # note: $X_CFLAGS includes $x_includes
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
   if test \! -z "$libdir" ; then
     LDFLAGS="$LDFLAGS -L$libdir"
   fi
-  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  if test \! -z "$x_libraries" ; then
-    LDFLAGS="$LDFLAGS -L$x_libraries"
-  fi
+  # note: $X_LIBS includes $x_libraries
+  LDFLAGS="$LDFLAGS $X_LIBS"
+
   echo $ac_n "checking for XScreenSaverRegister in -lXss""... $ac_c" 1>&6
-echo "configure:3640: checking for XScreenSaverRegister in -lXss" >&5
+echo "configure:3645: checking for XScreenSaverRegister in -lXss" >&5
 ac_lib_var=`echo Xss'_'XScreenSaverRegister | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3633,7 +3638,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lXss -lX11 -lXext -lm $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3648 "configure"
+#line 3653 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3644,7 +3649,7 @@ int main() {
 XScreenSaverRegister()
 ; return 0; }
 EOF
-if { (eval echo configure:3659: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3664: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3668,7 +3673,7 @@ fi
   LDFLAGS="$ac_save_LDFLAGS"
       fi
 
-    if test $have_mit = yes; then
+    if test "$have_mit" = yes; then
       cat >> confdefs.h <<\EOF
 #define HAVE_MIT_SAVER_EXTENSION 1
 EOF
@@ -3677,7 +3682,7 @@ EOF
 
     fi
 
-  elif test $with_mit != no; then
+  elif test "$with_mit" != no; then
     echo "error: must be yes or no: --with-mit-ext=$with_mit"
     exit 1
   fi
@@ -3704,7 +3709,7 @@ fi
 
     /*)
      echo $ac_n "checking for XIDLE headers""... $ac_c" 1>&6
-echo "configure:3719: checking for XIDLE headers" >&5
+echo "configure:3724: checking for XIDLE headers" >&5
      d=$with_xidle/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -3714,7 +3719,7 @@ echo "configure:3719: checking for XIDLE headers" >&5
      fi
 
      echo $ac_n "checking for XIDLE libs""... $ac_c" 1>&6
-echo "configure:3729: checking for XIDLE libs" >&5
+echo "configure:3734: checking for XIDLE libs" >&5
      d=$with_xidle/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -3743,7 +3748,7 @@ echo "configure:3729: checking for XIDLE libs" >&5
    withval=
   
 
-if test $with_xidle = yes; then
+if test "$with_xidle" = yes; then
   
   ac_save_CPPFLAGS="$CPPFLAGS"
   if test \! -z "$includedir" ; then 
@@ -3752,17 +3757,17 @@ if test $with_xidle = yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/extensions/xidle.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/extensions/xidle.h""... $ac_c" 1>&6
-echo "configure:3767: checking for X11/extensions/xidle.h" >&5
+echo "configure:3772: checking for X11/extensions/xidle.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3772 "configure"
+#line 3777 "configure"
 #include "confdefs.h"
 #include <X11/extensions/xidle.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3777: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3782: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3788,7 +3793,7 @@ else
 fi
 
   CPPFLAGS="$ac_save_CPPFLAGS"
-elif test $with_xidle != no; then
+elif test "$with_xidle" != no; then
   echo "error: must be yes or no: --with-xidle-ext=$with_xidle"
   exit 1
 fi
@@ -3814,7 +3819,7 @@ fi
 
     /*)
      echo $ac_n "checking for XSHM headers""... $ac_c" 1>&6
-echo "configure:3829: checking for XSHM headers" >&5
+echo "configure:3834: checking for XSHM headers" >&5
      d=$with_xshm/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -3824,7 +3829,7 @@ echo "configure:3829: checking for XSHM headers" >&5
      fi
 
      echo $ac_n "checking for XSHM libs""... $ac_c" 1>&6
-echo "configure:3839: checking for XSHM libs" >&5
+echo "configure:3844: checking for XSHM libs" >&5
      d=$with_xshm/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -3853,7 +3858,7 @@ echo "configure:3839: checking for XSHM libs" >&5
    withval=
   
 
-if test $with_xshm = yes; then
+if test "$with_xshm" = yes; then
 
   # first check for Xshm.h.
   
@@ -3864,17 +3869,17 @@ if test $with_xshm = yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/extensions/XShm.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/extensions/XShm.h""... $ac_c" 1>&6
-echo "configure:3879: checking for X11/extensions/XShm.h" >&5
+echo "configure:3884: checking for X11/extensions/XShm.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3884 "configure"
+#line 3889 "configure"
 #include "confdefs.h"
 #include <X11/extensions/XShm.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3889: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3894: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3898,7 +3903,7 @@ fi
   CPPFLAGS="$ac_save_CPPFLAGS"
 
   # if that succeeded, then check for sys/ipc.h.
-  if test $have_xshm = yes; then
+  if test "$have_xshm" = yes; then
     have_xshm=no
     
   ac_save_CPPFLAGS="$CPPFLAGS"
@@ -3908,17 +3913,17 @@ fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "sys/ipc.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for sys/ipc.h""... $ac_c" 1>&6
-echo "configure:3923: checking for sys/ipc.h" >&5
+echo "configure:3928: checking for sys/ipc.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3928 "configure"
+#line 3933 "configure"
 #include "confdefs.h"
 #include <sys/ipc.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3933: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3938: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3943,7 +3948,7 @@ fi
   fi
 
   # if that succeeded, then check for sys/shm.h.
-  if test $have_xshm = yes; then
+  if test "$have_xshm" = yes; then
     have_xshm=no
     
   ac_save_CPPFLAGS="$CPPFLAGS"
@@ -3953,17 +3958,17 @@ fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "sys/shm.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for sys/shm.h""... $ac_c" 1>&6
-echo "configure:3968: checking for sys/shm.h" >&5
+echo "configure:3973: checking for sys/shm.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3973 "configure"
+#line 3978 "configure"
 #include "confdefs.h"
 #include <sys/shm.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3978: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3983: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3998,21 +4003,21 @@ fi
       
   ac_save_CPPFLAGS="$CPPFLAGS"
   ac_save_LDFLAGS="$LDFLAGS"
+
   if test \! -z "$includedir" ; then 
     CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
-  if test \! -z "$includedir" ; then 
-    CPPFLAGS="$CPPFLAGS -I$includedir"
-  fi
+  # note: $X_CFLAGS includes $x_includes
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
   if test \! -z "$libdir" ; then
     LDFLAGS="$LDFLAGS -L$libdir"
   fi
-  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  if test \! -z "$x_libraries" ; then
-    LDFLAGS="$LDFLAGS -L$x_libraries"
-  fi
+  # note: $X_LIBS includes $x_libraries
+  LDFLAGS="$LDFLAGS $X_LIBS"
+
   echo $ac_n "checking for XShmQueryExtension in -lXextSam""... $ac_c" 1>&6
-echo "configure:4027: checking for XShmQueryExtension in -lXextSam" >&5
+echo "configure:4032: checking for XShmQueryExtension in -lXextSam" >&5
 ac_lib_var=`echo XextSam'_'XShmQueryExtension | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4020,7 +4025,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lXextSam -lX11 -lXext -lm $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4035 "configure"
+#line 4040 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4031,7 +4036,7 @@ int main() {
 XShmQueryExtension()
 ; return 0; }
 EOF
-if { (eval echo configure:4046: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4051: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4057,14 +4062,14 @@ fi
   esac
 
   # if that succeeded, then we've really got it.
-  if test $have_xshm = yes; then
+  if test "$have_xshm" = yes; then
     cat >> confdefs.h <<\EOF
 #define HAVE_XSHM_EXTENSION 1
 EOF
 
   fi
 
-elif test $with_xshm != no; then
+elif test "$with_xshm" != no; then
   echo "error: must be yes or no: --with-xshm-ext=$with_xshm"
   exit 1
 fi
@@ -4090,7 +4095,7 @@ fi
 
     /*)
      echo $ac_n "checking for SGI-VIDEO-CONTROL headers""... $ac_c" 1>&6
-echo "configure:4105: checking for SGI-VIDEO-CONTROL headers" >&5
+echo "configure:4110: checking for SGI-VIDEO-CONTROL headers" >&5
      d=$with_sgivc/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -4100,7 +4105,7 @@ echo "configure:4105: checking for SGI-VIDEO-CONTROL headers" >&5
      fi
 
      echo $ac_n "checking for SGI-VIDEO-CONTROL libs""... $ac_c" 1>&6
-echo "configure:4115: checking for SGI-VIDEO-CONTROL libs" >&5
+echo "configure:4120: checking for SGI-VIDEO-CONTROL libs" >&5
      d=$with_sgivc/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -4129,7 +4134,7 @@ echo "configure:4115: checking for SGI-VIDEO-CONTROL libs" >&5
    withval=
   
 
-if test $with_sgivc = yes; then
+if test "$with_sgivc" = yes; then
 
   # first check for XSGIvc.h
   
@@ -4140,17 +4145,17 @@ if test $with_sgivc = yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/extensions/XSGIvc.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/extensions/XSGIvc.h""... $ac_c" 1>&6
-echo "configure:4155: checking for X11/extensions/XSGIvc.h" >&5
+echo "configure:4160: checking for X11/extensions/XSGIvc.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4160 "configure"
+#line 4165 "configure"
 #include "confdefs.h"
 #include <X11/extensions/XSGIvc.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4165: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4170: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4174,26 +4179,26 @@ fi
   CPPFLAGS="$ac_save_CPPFLAGS"
 
   # if that succeeded, then check for the -lXsgivc
-  if test $have_sgivc = yes; then
+  if test "$have_sgivc" = yes; then
     have_sgivc=no
     
   ac_save_CPPFLAGS="$CPPFLAGS"
   ac_save_LDFLAGS="$LDFLAGS"
+
   if test \! -z "$includedir" ; then 
     CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
-  if test \! -z "$includedir" ; then 
-    CPPFLAGS="$CPPFLAGS -I$includedir"
-  fi
+  # note: $X_CFLAGS includes $x_includes
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
   if test \! -z "$libdir" ; then
     LDFLAGS="$LDFLAGS -L$libdir"
   fi
-  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  if test \! -z "$x_libraries" ; then
-    LDFLAGS="$LDFLAGS -L$x_libraries"
-  fi
+  # note: $X_LIBS includes $x_libraries
+  LDFLAGS="$LDFLAGS $X_LIBS"
+
   echo $ac_n "checking for XSGIvcQueryGammaMap in -lXsgivc""... $ac_c" 1>&6
-echo "configure:4208: checking for XSGIvcQueryGammaMap in -lXsgivc" >&5
+echo "configure:4213: checking for XSGIvcQueryGammaMap in -lXsgivc" >&5
 ac_lib_var=`echo Xsgivc'_'XSGIvcQueryGammaMap | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4201,7 +4206,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lXsgivc -lXext -lX11 $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4216 "configure"
+#line 4221 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4212,7 +4217,7 @@ int main() {
 XSGIvcQueryGammaMap()
 ; return 0; }
 EOF
-if { (eval echo configure:4227: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4232: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4237,14 +4242,14 @@ fi
   fi
 
   # if that succeeded, then we've really got it.
-  if test $have_sgivc = yes; then
+  if test "$have_sgivc" = yes; then
     cat >> confdefs.h <<\EOF
 #define HAVE_SGI_VC_EXTENSION 1
 EOF
 
   fi
 
-elif test $with_sgivc != no; then
+elif test "$with_sgivc" != no; then
   echo "error: must be yes or no: --with-sgivc-ext=$with_sgivc"
   exit 1
 fi
@@ -4270,7 +4275,7 @@ fi
 
     /*)
      echo $ac_n "checking for DPMS headers""... $ac_c" 1>&6
-echo "configure:4285: checking for DPMS headers" >&5
+echo "configure:4290: checking for DPMS headers" >&5
      d=$with_dpms/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -4280,7 +4285,7 @@ echo "configure:4285: checking for DPMS headers" >&5
      fi
 
      echo $ac_n "checking for DPMS libs""... $ac_c" 1>&6
-echo "configure:4295: checking for DPMS libs" >&5
+echo "configure:4300: checking for DPMS libs" >&5
      d=$with_dpms/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -4309,7 +4314,7 @@ echo "configure:4295: checking for DPMS libs" >&5
    withval=
   
 
-if test $with_dpms = yes; then
+if test "$with_dpms" = yes; then
 
   # first check for dpms.h
   
@@ -4320,17 +4325,17 @@ if test $with_dpms = yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/extensions/dpms.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/extensions/dpms.h""... $ac_c" 1>&6
-echo "configure:4335: checking for X11/extensions/dpms.h" >&5
+echo "configure:4340: checking for X11/extensions/dpms.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4340 "configure"
+#line 4345 "configure"
 #include "confdefs.h"
 #include <X11/extensions/dpms.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4345: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4350: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4354,26 +4359,26 @@ fi
   CPPFLAGS="$ac_save_CPPFLAGS"
 
   # if that succeeded, then check for the -lXdpms
-  if test $have_dpms = yes; then
+  if test "$have_dpms" = yes; then
     have_dpms=no
     
   ac_save_CPPFLAGS="$CPPFLAGS"
   ac_save_LDFLAGS="$LDFLAGS"
+
   if test \! -z "$includedir" ; then 
     CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
-  if test \! -z "$includedir" ; then 
-    CPPFLAGS="$CPPFLAGS -I$includedir"
-  fi
+  # note: $X_CFLAGS includes $x_includes
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
   if test \! -z "$libdir" ; then
     LDFLAGS="$LDFLAGS -L$libdir"
   fi
-  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  if test \! -z "$x_libraries" ; then
-    LDFLAGS="$LDFLAGS -L$x_libraries"
-  fi
+  # note: $X_LIBS includes $x_libraries
+  LDFLAGS="$LDFLAGS $X_LIBS"
+
   echo $ac_n "checking for DPMSInfo in -lXdpms""... $ac_c" 1>&6
-echo "configure:4388: checking for DPMSInfo in -lXdpms" >&5
+echo "configure:4393: checking for DPMSInfo in -lXdpms" >&5
 ac_lib_var=`echo Xdpms'_'DPMSInfo | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4381,7 +4386,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lXdpms -lXext -lX11 $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4396 "configure"
+#line 4401 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4392,7 +4397,7 @@ int main() {
 DPMSInfo()
 ; return 0; }
 EOF
-if { (eval echo configure:4407: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4412: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4417,14 +4422,14 @@ fi
   fi
 
   # if that succeeded, then we've really got it.
-  if test $have_dpms = yes; then
+  if test "$have_dpms" = yes; then
     cat >> confdefs.h <<\EOF
 #define HAVE_DPMS_EXTENSION 1
 EOF
 
   fi
 
-elif test $with_dpms != no; then
+elif test "$with_dpms" != no; then
   echo "error: must be yes or no: --with-dpms-ext=$with_dpms"
   exit 1
 fi
@@ -4455,7 +4460,7 @@ fi
 
     /*)
      echo $ac_n "checking for Motif headers""... $ac_c" 1>&6
-echo "configure:4470: checking for Motif headers" >&5
+echo "configure:4475: checking for Motif headers" >&5
      d=$with_motif/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -4465,7 +4470,7 @@ echo "configure:4470: checking for Motif headers" >&5
      fi
 
      echo $ac_n "checking for Motif libs""... $ac_c" 1>&6
-echo "configure:4480: checking for Motif libs" >&5
+echo "configure:4485: checking for Motif libs" >&5
      d=$with_motif/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -4510,7 +4515,7 @@ fi
 
     /*)
      echo $ac_n "checking for Athena headers""... $ac_c" 1>&6
-echo "configure:4525: checking for Athena headers" >&5
+echo "configure:4530: checking for Athena headers" >&5
      d=$with_athena/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -4520,7 +4525,7 @@ echo "configure:4525: checking for Athena headers" >&5
      fi
 
      echo $ac_n "checking for Athena libs""... $ac_c" 1>&6
-echo "configure:4535: checking for Athena libs" >&5
+echo "configure:4540: checking for Athena libs" >&5
      d=$with_athena/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -4549,25 +4554,25 @@ echo "configure:4535: checking for Athena libs" >&5
    withval=
   
 
-if test $with_motif != yes -a $with_motif != no ; then
+if test "$with_motif" != yes -a "$with_motif" != no ; then
   echo "error: must be yes or no: --with-motif=$with_motif"
   exit 1
 fi
 
-if test $with_athena != yes -a $with_athena != no ; then
+if test "$with_athena" != yes -a "$with_athena" != no ; then
   echo "error: must be yes or no: --with-athena=$with_athena"
   exit 1
 fi
 
 
 # Saying --without-motif is the same as saying --with-athena.
-if test $with_motif_req = no ; then
+if test "$with_motif_req" = no ; then
   with_athena_req=yes
   with_athena=yes
 fi
 
 # Saying --without-athena is the same as saying --with-motif.
-if test $with_athena_req = no ; then
+if test "$with_athena_req" = no ; then
   with_motif_req=yes
   with_motif=yes
 fi
@@ -4583,17 +4588,17 @@ check_motif() {
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "Xm/Xm.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for Xm/Xm.h""... $ac_c" 1>&6
-echo "configure:4598: checking for Xm/Xm.h" >&5
+echo "configure:4603: checking for Xm/Xm.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4603 "configure"
+#line 4608 "configure"
 #include "confdefs.h"
 #include <Xm/Xm.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4608: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4613: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4614,7 +4619,7 @@ if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
 #define HAVE_MOTIF 1
 EOF
 
-                    SAVER_LIBS="-lXm $SAVER_LIBS"
+                    TOOLKIT_LIBS="-lXm $TOOLKIT_LIBS"
 else
   echo "$ac_t""no" 1>&6
 fi
@@ -4633,17 +4638,17 @@ check_athena() {
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/Xaw/Dialog.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/Xaw/Dialog.h""... $ac_c" 1>&6
-echo "configure:4648: checking for X11/Xaw/Dialog.h" >&5
+echo "configure:4653: checking for X11/Xaw/Dialog.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4653 "configure"
+#line 4658 "configure"
 #include "confdefs.h"
 #include <X11/Xaw/Dialog.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4658: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4663: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4665,24 +4670,25 @@ else
 fi
 
   CPPFLAGS="$ac_save_CPPFLAGS"
-  
+  if test "$have_athena" = yes; then
+    
   ac_save_CPPFLAGS="$CPPFLAGS"
   ac_save_LDFLAGS="$LDFLAGS"
+
   if test \! -z "$includedir" ; then 
     CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
-  if test \! -z "$includedir" ; then 
-    CPPFLAGS="$CPPFLAGS -I$includedir"
-  fi
+  # note: $X_CFLAGS includes $x_includes
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
   if test \! -z "$libdir" ; then
     LDFLAGS="$LDFLAGS -L$libdir"
   fi
-  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  if test \! -z "$x_libraries" ; then
-    LDFLAGS="$LDFLAGS -L$x_libraries"
-  fi
+  # note: $X_LIBS includes $x_libraries
+  LDFLAGS="$LDFLAGS $X_LIBS"
+
   echo $ac_n "checking for Xaw3dComputeTopShadowRGB in -lXaw3d""... $ac_c" 1>&6
-echo "configure:4697: checking for Xaw3dComputeTopShadowRGB in -lXaw3d" >&5
+echo "configure:4703: checking for Xaw3dComputeTopShadowRGB in -lXaw3d" >&5
 ac_lib_var=`echo Xaw3d'_'Xaw3dComputeTopShadowRGB | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4690,7 +4696,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lXaw3d -lXt -lXmu -lXext -lX11 $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4705 "configure"
+#line 4711 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4701,7 +4707,7 @@ int main() {
 Xaw3dComputeTopShadowRGB()
 ; return 0; }
 EOF
-if { (eval echo configure:4716: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4722: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4723,11 +4729,12 @@ fi
 
   CPPFLAGS="$ac_save_CPPFLAGS"
   LDFLAGS="$ac_save_LDFLAGS"
+  fi
 
-  if test $have_athena3d = yes; then
-    SAVER_LIBS="-lXaw3d $SAVER_LIBS"
-  elif test $have_athena = yes; then
-    SAVER_LIBS="-lXaw $SAVER_LIBS"
+  if test "$have_athena3d" = yes; then
+    TOOLKIT_LIBS="-lXaw3d $TOOLKIT_LIBS"
+  elif test "$have_athena" = yes; then
+    TOOLKIT_LIBS="-lXaw $TOOLKIT_LIBS"
   fi
 }
 
@@ -4738,20 +4745,20 @@ fi
 # If they asked for neither, check motif then athena.
 
 proselytize_motif=yes
-if test $with_motif = yes; then
+if test "$with_motif" = yes; then
   # asked for both, or for motif only
   check_motif
-  if test $have_motif = yes; then
+  if test "$have_motif" = yes; then
     with_athena=no
     with_athena_req=no
   else
     check_athena
   fi
 
-elif test $with_athena = yes; then
+elif test "$with_athena" = yes; then
   # asked for athena only
   check_athena
-  if test $have_athena = yes; then
+  if test "$have_athena" = yes; then
     with_motif=no
     proselytize_motif=no
   else
@@ -4761,7 +4768,7 @@ elif test $with_athena = yes; then
 else
   # asked for neither
   check_motif
-  if test $have_motif = yes; then
+  if test "$have_motif" = yes; then
     with_athena=no
   else
     check_athena
@@ -4769,15 +4776,15 @@ else
 
 fi
 
-if test $have_motif = yes; then
+if test "$have_motif" = yes; then
   proselytize_motif=no
 fi
 
 # If we have Athena, check whether it's a version that includes
 # XawViewportSetCoordinates in Viewport.h (R3 (or R4?) don't.)
-if test $have_athena = yes ; then
+if test "$have_athena" = yes ; then
   echo $ac_n "checking for XawViewportSetCoordinates in Viewport.h""... $ac_c" 1>&6
-echo "configure:4792: checking for XawViewportSetCoordinates in Viewport.h" >&5
+echo "configure:4799: checking for XawViewportSetCoordinates in Viewport.h" >&5
 if eval "test \"`echo '$''{'ac_cv_have_XawViewportSetCoordinates'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4789,7 +4796,7 @@ else
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 4804 "configure"
+#line 4811 "configure"
 #include "confdefs.h"
 #include <X11/Xaw/Viewport.h>
 EOF
@@ -4804,7 +4811,7 @@ rm -f conftest*
 fi
 
 echo "$ac_t""$ac_cv_have_XawViewportSetCoordinates" 1>&6
-  if test $ac_cv_have_XawViewportSetCoordinates = yes ; then
+  if test "$ac_cv_have_XawViewportSetCoordinates" = yes ; then
     cat >> confdefs.h <<\EOF
 #define HAVE_XawViewportSetCoordinates 1
 EOF
@@ -4816,9 +4823,9 @@ fi
 # If we have Motif, check whether it's really LessTif.
 #
 have_lesstif=no
-if test $have_motif = yes ; then
+if test "$have_motif" = yes ; then
   echo $ac_n "checking whether Motif is really LessTif""... $ac_c" 1>&6
-echo "configure:4833: checking whether Motif is really LessTif" >&5
+echo "configure:4840: checking whether Motif is really LessTif" >&5
 if eval "test \"`echo '$''{'ac_cv_have_lesstif'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4829,14 +4836,14 @@ else
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 4844 "configure"
+#line 4851 "configure"
 #include "confdefs.h"
 #include <Xm/Xm.h>
 int main() {
 long vers = LesstifVersion;
 ; return 0; }
 EOF
-if { (eval echo configure:4851: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4858: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_have_lesstif=yes
 else
@@ -4860,11 +4867,11 @@ unset ac_cv_lesstif_version_string
 lesstif_version=unknown
 lesstif_version_string=unknown
 
-if test $have_lesstif = yes ; then
+if test "$have_lesstif" = yes ; then
   ltv=unknown
   echo unknown > conftest-lt
   echo $ac_n "checking LessTif version number""... $ac_c" 1>&6
-echo "configure:4879: checking LessTif version number" >&5
+echo "configure:4886: checking LessTif version number" >&5
 if eval "test \"`echo '$''{'ac_cv_lesstif_version_string'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4879,7 +4886,7 @@ else
                     ac_cv_lesstif_version_string=unknown
 else
   cat > conftest.$ac_ext <<EOF
-#line 4894 "configure"
+#line 4901 "configure"
 #include "confdefs.h"
 #include <stdio.h>
                     #include <Xm/Xm.h>
@@ -4892,7 +4899,7 @@ else
                       exit(0);
                     }
 EOF
-if { (eval echo configure:4907: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4914: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ltv=`cat conftest-lt`
                     ac_cv_lesstif_version=`echo $ltv | sed 's/ .*//'`
@@ -4923,26 +4930,26 @@ fi
 # I have no idea.
 #
 have_xp_ext=no
-if test $have_motif = yes ; then
+if test "$have_motif" = yes ; then
    have_xp_ext=no
    
   ac_save_CPPFLAGS="$CPPFLAGS"
   ac_save_LDFLAGS="$LDFLAGS"
+
   if test \! -z "$includedir" ; then 
     CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
-  if test \! -z "$includedir" ; then 
-    CPPFLAGS="$CPPFLAGS -I$includedir"
-  fi
+  # note: $X_CFLAGS includes $x_includes
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
   if test \! -z "$libdir" ; then
     LDFLAGS="$LDFLAGS -L$libdir"
   fi
-  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  if test \! -z "$x_libraries" ; then
-    LDFLAGS="$LDFLAGS -L$x_libraries"
-  fi
+  # note: $X_LIBS includes $x_libraries
+  LDFLAGS="$LDFLAGS $X_LIBS"
+
   echo $ac_n "checking for XpQueryExtension in -lXp""... $ac_c" 1>&6
-echo "configure:4957: checking for XpQueryExtension in -lXp" >&5
+echo "configure:4964: checking for XpQueryExtension in -lXp" >&5
 ac_lib_var=`echo Xp'_'XpQueryExtension | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4950,7 +4957,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lXp -lX11 -lXext -lm $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4965 "configure"
+#line 4972 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4961,7 +4968,7 @@ int main() {
 XpQueryExtension()
 ; return 0; }
 EOF
-if { (eval echo configure:4976: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4983: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4976,7 +4983,7 @@ LIBS="$ac_save_LIBS"
 fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-  have_xp_ext=yes; SAVER_LIBS="$SAVER_LIBS -lXp"
+  have_xp_ext=yes; TOOLKIT_LIBS="$TOOLKIT_LIBS -lXp"
 else
   echo "$ac_t""no" 1>&6
 fi
@@ -5006,7 +5013,7 @@ fi
 
     /*)
      echo $ac_n "checking for XPM headers""... $ac_c" 1>&6
-echo "configure:5021: checking for XPM headers" >&5
+echo "configure:5028: checking for XPM headers" >&5
      d=$with_xpm/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -5016,7 +5023,7 @@ echo "configure:5021: checking for XPM headers" >&5
      fi
 
      echo $ac_n "checking for XPM libs""... $ac_c" 1>&6
-echo "configure:5031: checking for XPM libs" >&5
+echo "configure:5038: checking for XPM libs" >&5
      d=$with_xpm/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -5045,7 +5052,7 @@ echo "configure:5031: checking for XPM libs" >&5
    withval=
   
 
-if test $with_xpm = yes; then
+if test "$with_xpm" = yes; then
   
   ac_save_CPPFLAGS="$CPPFLAGS"
   if test \! -z "$includedir" ; then 
@@ -5054,17 +5061,17 @@ if test $with_xpm = yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/xpm.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/xpm.h""... $ac_c" 1>&6
-echo "configure:5069: checking for X11/xpm.h" >&5
+echo "configure:5076: checking for X11/xpm.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5074 "configure"
+#line 5081 "configure"
 #include "confdefs.h"
 #include <X11/xpm.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5079: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5086: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5091,7 +5098,7 @@ else
 fi
 
   CPPFLAGS="$ac_save_CPPFLAGS"
-elif test $with_xpm != no; then
+elif test "$with_xpm" != no; then
   echo "error: must be yes or no: --with-xpm=$with_xpm"
   exit 1
 fi
@@ -5118,7 +5125,7 @@ fi
 
     /*)
      echo $ac_n "checking for GL headers""... $ac_c" 1>&6
-echo "configure:5133: checking for GL headers" >&5
+echo "configure:5140: checking for GL headers" >&5
      d=$with_gl/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -5128,7 +5135,7 @@ echo "configure:5133: checking for GL headers" >&5
      fi
 
      echo $ac_n "checking for GL libs""... $ac_c" 1>&6
-echo "configure:5143: checking for GL libs" >&5
+echo "configure:5150: checking for GL libs" >&5
      d=$with_gl/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -5160,7 +5167,7 @@ echo "configure:5143: checking for GL libs" >&5
 ac_mesagl_version=unknown
 ac_mesagl_version_string=unknown
 
-if test $with_gl = yes; then
+if test "$with_gl" = yes; then
   
   ac_save_CPPFLAGS="$CPPFLAGS"
   if test \! -z "$includedir" ; then 
@@ -5169,17 +5176,17 @@ if test $with_gl = yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "GL/gl.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for GL/gl.h""... $ac_c" 1>&6
-echo "configure:5184: checking for GL/gl.h" >&5
+echo "configure:5191: checking for GL/gl.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5189 "configure"
+#line 5196 "configure"
 #include "confdefs.h"
 #include <GL/gl.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5194: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5201: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5201,7 +5208,7 @@ else
 fi
 
   CPPFLAGS="$ac_save_CPPFLAGS"
-  if test $have_gl = yes ; then
+  if test "$have_gl" = yes ; then
     
   ac_save_CPPFLAGS="$CPPFLAGS"
   if test \! -z "$includedir" ; then 
@@ -5210,17 +5217,17 @@ fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "GL/glx.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for GL/glx.h""... $ac_c" 1>&6
-echo "configure:5225: checking for GL/glx.h" >&5
+echo "configure:5232: checking for GL/glx.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5230 "configure"
+#line 5237 "configure"
 #include "confdefs.h"
 #include <GL/glx.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5235: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5242: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5246,7 +5253,7 @@ fi
 
   # If we have the headers, try and figure out which vendor it's from.
   #
-  if test $have_gl = yes ; then
+  if test "$have_gl" = yes ; then
 
     cat >> confdefs.h <<\EOF
 #define HAVE_GL 1
@@ -5257,7 +5264,7 @@ EOF
     # to link against.
     #
     echo $ac_n "checking whether GL is really MesaGL""... $ac_c" 1>&6
-echo "configure:5272: checking whether GL is really MesaGL" >&5
+echo "configure:5279: checking whether GL is really MesaGL" >&5
     if eval "test \"`echo '$''{'ac_cv_have_mesa_gl'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5269,7 +5276,7 @@ else
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 5284 "configure"
+#line 5291 "configure"
 #include "confdefs.h"
 #include <GL/glx.h>
 EOF
@@ -5287,7 +5294,7 @@ fi
     ac_have_mesa_gl=$ac_cv_have_mesa_gl
     echo "$ac_t""$ac_have_mesa_gl" 1>&6
 
-    if test $ac_have_mesa_gl = no ; then
+    if test "$ac_have_mesa_gl" = no ; then
       gl_lib_1="GL"
       GL_LIBS="-lGL -lGLU"
     else
@@ -5303,26 +5310,36 @@ EOF
     # If it's MesaGL, we'd like to issue a warning if the version number
     # is less than or equal to 2.6, because that version had a security bug.
     #
-    if test $ac_have_mesa_gl = yes; then
+    if test "$ac_have_mesa_gl" = yes; then
 
       # don't cache these.
       unset ac_cv_mesagl_version
       unset ac_cv_mesagl_version_string
 
       echo $ac_n "checking MesaGL version number""... $ac_c" 1>&6
-echo "configure:5325: checking MesaGL version number" >&5
+echo "configure:5332: checking MesaGL version number" >&5
       if eval "test \"`echo '$''{'ac_cv_mesagl_version_string'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5330 "configure"
+#line 5337 "configure"
 #include "confdefs.h"
 #include <GL/gl.h>
 #configure: MESA_MAJOR_VERSION MESA_MINOR_VERSION
 EOF
 
+        ac_save_CPPFLAGS="$CPPFLAGS"
+        if test \! -z "$includedir" ; then 
+          CPPFLAGS="$CPPFLAGS -I$includedir"
+        fi
+        CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
         mglv=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | sed -n \
              's/^#configure:.*\([0-9][0-9]*\).*\([0-9][0-9]*\).*$/\1.\2/p'`
+         rm -f conftest.$ac_ext
+
+        CPPFLAGS="$ac_save_CPPFLAGS"
+
         if test "$mglv" = ""; then
            ac_mesagl_version=unknown
            ac_mesagl_version_string=unknown
@@ -5331,6 +5348,10 @@ EOF
            maj=`echo $mglv | sed -n 's/\..*//p'`
            min=`echo $mglv | sed -n 's/.*\.//p'`
            ac_mesagl_version=`echo "$maj * 1000 + $min" | bc`
+           if test -z "$ac_mesagl_version"; then
+            ac_mesagl_version=unknown
+             ac_mesagl_version_string=unknown
+          fi
          fi
          ac_cv_mesagl_version=$ac_mesagl_version
          ac_cv_mesagl_version_string=$ac_mesagl_version_string
@@ -5348,21 +5369,21 @@ fi
     
   ac_save_CPPFLAGS="$CPPFLAGS"
   ac_save_LDFLAGS="$LDFLAGS"
+
   if test \! -z "$includedir" ; then 
     CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
-  if test \! -z "$includedir" ; then 
-    CPPFLAGS="$CPPFLAGS -I$includedir"
-  fi
+  # note: $X_CFLAGS includes $x_includes
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
   if test \! -z "$libdir" ; then
     LDFLAGS="$LDFLAGS -L$libdir"
   fi
-  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  if test \! -z "$x_libraries" ; then
-    LDFLAGS="$LDFLAGS -L$x_libraries"
-  fi
+  # note: $X_LIBS includes $x_libraries
+  LDFLAGS="$LDFLAGS $X_LIBS"
+
   echo $ac_n "checking for glBindTexture in -l$gl_lib_1""... $ac_c" 1>&6
-echo "configure:5377: checking for glBindTexture in -l$gl_lib_1" >&5
+echo "configure:5398: checking for glBindTexture in -l$gl_lib_1" >&5
 ac_lib_var=`echo $gl_lib_1'_'glBindTexture | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5370,7 +5391,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$gl_lib_1 $GL_LIBS -lX11 -lXext -lm $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5385 "configure"
+#line 5406 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5381,7 +5402,7 @@ int main() {
 glBindTexture()
 ; return 0; }
 EOF
-if { (eval echo configure:5396: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5417: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5409,7 +5430,7 @@ fi
 
   fi
 
-elif test $with_gl != no; then
+elif test "$with_gl" != no; then
   echo "error: must be yes or no: --with-gl=$with_gl"
   exit 1
 fi
@@ -5435,7 +5456,7 @@ fi
 
     /*)
      echo $ac_n "checking for XReadDisplay headers""... $ac_c" 1>&6
-echo "configure:5450: checking for XReadDisplay headers" >&5
+echo "configure:5471: checking for XReadDisplay headers" >&5
      d=$with_readdisplay/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -5445,7 +5466,7 @@ echo "configure:5450: checking for XReadDisplay headers" >&5
      fi
 
      echo $ac_n "checking for XReadDisplay libs""... $ac_c" 1>&6
-echo "configure:5460: checking for XReadDisplay libs" >&5
+echo "configure:5481: checking for XReadDisplay libs" >&5
      d=$with_readdisplay/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -5474,7 +5495,7 @@ echo "configure:5460: checking for XReadDisplay libs" >&5
    withval=
   
 
-if test $with_readdisplay = yes; then
+if test "$with_readdisplay" = yes; then
   
   ac_save_CPPFLAGS="$CPPFLAGS"
   if test \! -z "$includedir" ; then 
@@ -5483,17 +5504,17 @@ if test $with_readdisplay = yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/extensions/readdisplay.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/extensions/readdisplay.h""... $ac_c" 1>&6
-echo "configure:5498: checking for X11/extensions/readdisplay.h" >&5
+echo "configure:5519: checking for X11/extensions/readdisplay.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5503 "configure"
+#line 5524 "configure"
 #include "confdefs.h"
 #include <X11/extensions/readdisplay.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5508: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5529: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5518,7 +5539,7 @@ else
 fi
 
   CPPFLAGS="$ac_save_CPPFLAGS"
-elif test $with_readdisplay != no; then
+elif test "$with_readdisplay" != no; then
   echo "error: must be yes or no: --with-readdisplay=$with_readdisplay"
   exit 1
 fi
@@ -5544,7 +5565,7 @@ fi
 
     /*)
      echo $ac_n "checking for Iris Video headers""... $ac_c" 1>&6
-echo "configure:5559: checking for Iris Video headers" >&5
+echo "configure:5580: checking for Iris Video headers" >&5
      d=$with_sgivideo/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -5554,7 +5575,7 @@ echo "configure:5559: checking for Iris Video headers" >&5
      fi
 
      echo $ac_n "checking for Iris Video libs""... $ac_c" 1>&6
-echo "configure:5569: checking for Iris Video libs" >&5
+echo "configure:5590: checking for Iris Video libs" >&5
      d=$with_sgivideo/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -5583,7 +5604,7 @@ echo "configure:5569: checking for Iris Video libs" >&5
    withval=
   
 
-if test $with_sgivideo = yes; then
+if test "$with_sgivideo" = yes; then
   
   ac_save_CPPFLAGS="$CPPFLAGS"
   if test \! -z "$includedir" ; then 
@@ -5592,17 +5613,17 @@ if test $with_sgivideo = yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "dmedia/vl.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for dmedia/vl.h""... $ac_c" 1>&6
-echo "configure:5607: checking for dmedia/vl.h" >&5
+echo "configure:5628: checking for dmedia/vl.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5612 "configure"
+#line 5633 "configure"
 #include "confdefs.h"
 #include <dmedia/vl.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5617: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5638: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5624,10 +5645,10 @@ else
 fi
 
   CPPFLAGS="$ac_save_CPPFLAGS"
-  if test $have_sgivideo = yes; then
+  if test "$have_sgivideo" = yes; then
     have_sgivideo=no
     echo $ac_n "checking for vlOpenVideo in -lvl""... $ac_c" 1>&6
-echo "configure:5642: checking for vlOpenVideo in -lvl" >&5
+echo "configure:5663: checking for vlOpenVideo in -lvl" >&5
 ac_lib_var=`echo vl'_'vlOpenVideo | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5635,7 +5656,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lvl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5650 "configure"
+#line 5671 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5646,7 +5667,7 @@ int main() {
 vlOpenVideo()
 ; return 0; }
 EOF
-if { (eval echo configure:5661: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5682: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5666,7 +5687,7 @@ else
   echo "$ac_t""no" 1>&6
 fi
 
-    if test $have_sgivideo = yes; then
+    if test "$have_sgivideo" = yes; then
       SGI_VIDEO_OBJS="$(UTILS_BIN)/sgivideo.o"
       SGI_VIDEO_LIBS="-lvl"
       cat >> confdefs.h <<\EOF
@@ -5675,7 +5696,7 @@ EOF
 
     fi
   fi
-elif test $with_sgivideo != no; then
+elif test "$with_sgivideo" != no; then
   echo "error: must be yes or no: --with-sgivideo=$with_sgivideo"
   exit 1
 fi
@@ -5714,7 +5735,7 @@ if test -n "$with_zippy_req" ; then
   case "$with_zippy_req" in
     /*)
       echo $ac_n "checking for $with_zippy_req""... $ac_c" 1>&6
-echo "configure:5729: checking for $with_zippy_req" >&5
+echo "configure:5750: checking for $with_zippy_req" >&5
       if test -x "$with_zippy_req" ; then
         echo "$ac_t""yes" 1>&6
       else
@@ -5728,7 +5749,7 @@ echo "configure:5729: checking for $with_zippy_req" >&5
       # Extract the first word of "$with_zippy_req", so it can be a program name with args.
 set dummy $with_zippy_req; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:5743: checking for $ac_word" >&5
+echo "configure:5764: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_zip2'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5774,7 +5795,7 @@ do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:5789: checking for $ac_word" >&5
+echo "configure:5810: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_emacs_exe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5807,7 +5828,7 @@ do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:5822: checking for $ac_word" >&5
+echo "configure:5843: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_xemacs_exe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5841,7 +5862,7 @@ done
 
   if test -n "$emacs_exe" ; then
     echo $ac_n "checking for emacs yow""... $ac_c" 1>&6
-echo "configure:5856: checking for emacs yow" >&5
+echo "configure:5877: checking for emacs yow" >&5
     #
     # get emacs to tell us where the libexec directory is.
     #
@@ -5851,7 +5872,7 @@ echo "configure:5856: checking for emacs yow" >&5
     #
     # try running libexec/yow and see if it exits without error.
     #
-    if test x"$dir" != x -a -x $dir/yow ; then
+    if test x"$dir" != x -a -x "$dir/yow" ; then
       if $dir/yow >&- 2>&- ; then
        ac_cv_zippy_program="$dir/yow"
        echo "$ac_t""$ac_cv_zippy_program" 1>&6
@@ -5863,7 +5884,7 @@ echo "configure:5856: checking for emacs yow" >&5
 
   if test -z "$ac_cv_zippy_program" ; then
     echo $ac_n "checking for xemacs yow""... $ac_c" 1>&6
-echo "configure:5878: checking for xemacs yow" >&5
+echo "configure:5899: checking for xemacs yow" >&5
     if test -n "$xemacs_exe" ; then
       #
       # get xemacs to tell us where the libexec directory is.
@@ -5874,7 +5895,7 @@ echo "configure:5878: checking for xemacs yow" >&5
       #
       # try running libexec/yow and see if it exits without error.
       #
-      if test x"$dir" != x -a -x $dir/yow ; then
+      if test x"$dir" != x -a -x "$dir/yow" ; then
         if $dir/yow >&- 2>&- ; then
          ac_cv_zippy_program="$dir/yow"
          echo "$ac_t""$ac_cv_zippy_program" 1>&6
@@ -5909,7 +5930,7 @@ do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:5924: checking for $ac_word" >&5
+echo "configure:5945: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_fortune'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5944,7 +5965,7 @@ do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:5959: checking for $ac_word" >&5
+echo "configure:5980: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_fortune'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6008,9 +6029,9 @@ else
   enable_locking=yes
 fi
 
-if test $enable_locking = yes; then
+if test "$enable_locking" = yes; then
   true
-elif test $enable_locking = no; then
+elif test "$enable_locking" = no; then
   cat >> confdefs.h <<\EOF
 #define NO_LOCKING 1
 EOF
@@ -6034,15 +6055,15 @@ else
   enable_vt_locking=yes
 fi
 
-if test $enable_vt_locking = yes; then
+if test "$enable_vt_locking" = yes; then
 
-  echo $ac_n "checking for VT_LOCKSWITCH ioctl""... $ac_c" 1>&6
-echo "configure:6052: checking for VT_LOCKSWITCH ioctl" >&5
+  echo $ac_n "checking for the VT_LOCKSWITCH ioctl""... $ac_c" 1>&6
+echo "configure:6073: checking for the VT_LOCKSWITCH ioctl" >&5
   if eval "test \"`echo '$''{'ac_cv_vt_lockswitch'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6057 "configure"
+#line 6078 "configure"
 #include "confdefs.h"
 #include <fcntl.h>
                    #include <sys/ioctl.h>
@@ -6051,7 +6072,7 @@ int main() {
 int x = VT_LOCKSWITCH; int y = VT_UNLOCKSWITCH;
 ; return 0; }
 EOF
-if { (eval echo configure:6066: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6087: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_vt_lockswitch=yes
 else
@@ -6066,25 +6087,26 @@ fi
   ac_vt_lockswitch=$ac_cv_vt_lockswitch
   echo "$ac_t""$ac_vt_lockswitch" 1>&6
 
-elif test $enable_locking = no; then
+elif test "$enable_locking" = no; then
   true
 else
   echo "error: must be yes or no: --enable-vt-locking=$enable_vt_locking"
   exit 1
 fi
 
-if test $ac_vt_lockswitch = yes; then
+if test "$ac_vt_lockswitch" = yes; then
   cat >> confdefs.h <<\EOF
 #define HAVE_VT_LOCKSWITCH 1
 EOF
 
   # the VT_LOCKSWITCH ioctl can only be used when running as root.
-  need_setuid=yes
+  # #### but it doesn't work yet, so don't worry about that for now.
+#  need_setuid=yes
 fi
 
 
 
-if test $enable_locking = yes; then
+if test "$enable_locking" = yes; then
 
   # Check for Kerberos.
   #
@@ -6104,7 +6126,7 @@ fi
 
     /*)
      echo $ac_n "checking for Kerberos headers""... $ac_c" 1>&6
-echo "configure:6119: checking for Kerberos headers" >&5
+echo "configure:6141: checking for Kerberos headers" >&5
      d=$with_kerberos/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -6114,7 +6136,7 @@ echo "configure:6119: checking for Kerberos headers" >&5
      fi
 
      echo $ac_n "checking for Kerberos libs""... $ac_c" 1>&6
-echo "configure:6129: checking for Kerberos libs" >&5
+echo "configure:6151: checking for Kerberos libs" >&5
      d=$with_kerberos/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -6143,9 +6165,9 @@ echo "configure:6129: checking for Kerberos libs" >&5
    withval=
   
 
-  if test $with_kerberos = yes; then
+  if test "$with_kerberos" = yes; then
     echo $ac_n "checking for Kerberos""... $ac_c" 1>&6
-echo "configure:6160: checking for Kerberos" >&5
+echo "configure:6182: checking for Kerberos" >&5
 if eval "test \"`echo '$''{'ac_cv_kerberos'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6156,14 +6178,14 @@ else
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 6171 "configure"
+#line 6193 "configure"
 #include "confdefs.h"
 #include <krb.h>
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:6178: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6200: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_kerberos=yes
 else
@@ -6177,7 +6199,7 @@ rm -f conftest*
 fi
 
 echo "$ac_t""$ac_cv_kerberos" 1>&6
-    if test $ac_cv_kerberos = yes ; then
+    if test "$ac_cv_kerberos" = yes ; then
       have_kerberos=yes
       cat >> confdefs.h <<\EOF
 #define HAVE_KERBEROS 1
@@ -6187,12 +6209,12 @@ EOF
       # from Tim Showalter <tjs+@andrew.cmu.edu>
       PASSWD_LIBS="$PASSWD_LIBS -lkrb -ldes"
       echo $ac_n "checking for res_search""... $ac_c" 1>&6
-echo "configure:6202: checking for res_search" >&5
+echo "configure:6224: checking for res_search" >&5
 if eval "test \"`echo '$''{'ac_cv_func_res_search'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6207 "configure"
+#line 6229 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char res_search(); below.  */
@@ -6215,7 +6237,7 @@ res_search();
 
 ; return 0; }
 EOF
-if { (eval echo configure:6230: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6252: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_res_search=yes"
 else
@@ -6233,7 +6255,7 @@ if eval "test \"`echo '$ac_cv_func_'res_search`\" = yes"; then
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for res_search in -lresolv""... $ac_c" 1>&6
-echo "configure:6248: checking for res_search in -lresolv" >&5
+echo "configure:6270: checking for res_search in -lresolv" >&5
 ac_lib_var=`echo resolv'_'res_search | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6241,7 +6263,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6256 "configure"
+#line 6278 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6252,7 +6274,7 @@ int main() {
 res_search()
 ; return 0; }
 EOF
-if { (eval echo configure:6267: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6289: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6278,7 +6300,7 @@ fi
 
 
     fi
-  elif test $with_kerberos != no; then
+  elif test "$with_kerberos" != no; then
     echo "error: must be yes or no: --with-kerberos=$with_kerberos"
     exit 1
   fi
@@ -6302,7 +6324,7 @@ fi
 
     /*)
      echo $ac_n "checking for shadow password headers""... $ac_c" 1>&6
-echo "configure:6317: checking for shadow password headers" >&5
+echo "configure:6339: checking for shadow password headers" >&5
      d=$with_shadow/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -6312,7 +6334,7 @@ echo "configure:6317: checking for shadow password headers" >&5
      fi
 
      echo $ac_n "checking for shadow password libs""... $ac_c" 1>&6
-echo "configure:6327: checking for shadow password libs" >&5
+echo "configure:6349: checking for shadow password libs" >&5
      d=$with_shadow/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -6341,9 +6363,9 @@ echo "configure:6327: checking for shadow password libs" >&5
    withval=
   
 
-  if test $with_shadow = no; then
+  if test "$with_shadow" = no; then
     passwd_cruft_done=yes
-  elif test $with_shadow != yes; then
+  elif test "$with_shadow" != yes; then
     echo "error: must be yes or no: --with-shadow=$with_shadow"
     exit 1
   fi
@@ -6351,9 +6373,9 @@ echo "configure:6327: checking for shadow password libs" >&5
 
   # Sun's "adjunct" passwords.
   #
-  if test $passwd_cruft_done = no ; then
+  if test "$passwd_cruft_done" = no ; then
     echo $ac_n "checking for Sun-style shadow passwords""... $ac_c" 1>&6
-echo "configure:6368: checking for Sun-style shadow passwords" >&5
+echo "configure:6390: checking for Sun-style shadow passwords" >&5
 if eval "test \"`echo '$''{'ac_cv_sun_adjunct'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6364,7 +6386,7 @@ else
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 6379 "configure"
+#line 6401 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
                                      #include <unistd.h>
@@ -6377,7 +6399,7 @@ struct passwd_adjunct *p = getpwanam("nobody");
                         const char *pw = p->pwa_passwd;
 ; return 0; }
 EOF
-if { (eval echo configure:6392: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6414: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_sun_adjunct=yes
 else
@@ -6391,7 +6413,7 @@ rm -f conftest*
 fi
 
 echo "$ac_t""$ac_cv_sun_adjunct" 1>&6
-    if test $ac_cv_sun_adjunct = yes; then
+    if test "$ac_cv_sun_adjunct" = yes; then
       have_shadow=yes
       need_setuid=yes
       passwd_cruft_done=yes
@@ -6404,9 +6426,9 @@ EOF
 
   # DEC and SCO so-called "enhanced" security.
   #
-  if test $passwd_cruft_done = no ; then
+  if test "$passwd_cruft_done" = no ; then
     echo $ac_n "checking for DEC-style shadow passwords""... $ac_c" 1>&6
-echo "configure:6421: checking for DEC-style shadow passwords" >&5
+echo "configure:6443: checking for DEC-style shadow passwords" >&5
 if eval "test \"`echo '$''{'ac_cv_enhanced_passwd'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6417,7 +6439,7 @@ else
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 6432 "configure"
+#line 6454 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
                                      #include <unistd.h>
@@ -6434,7 +6456,7 @@ struct pr_passwd *p;
                         pw = p->ufld.fd_encrypt;
 ; return 0; }
 EOF
-if { (eval echo configure:6449: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6471: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_enhanced_passwd=yes
 else
@@ -6460,7 +6482,7 @@ EOF
       # On SCO, getprpwnam() is in -lprot (which uses nap() from -lx)
       # (I'm told it needs -lcurses too, but I don't understand why.)
       echo $ac_n "checking for getprpwnam in -lprot""... $ac_c" 1>&6
-echo "configure:6475: checking for getprpwnam in -lprot" >&5
+echo "configure:6497: checking for getprpwnam in -lprot" >&5
 ac_lib_var=`echo prot'_'getprpwnam | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6468,7 +6490,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lprot -lx $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6483 "configure"
+#line 6505 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6479,7 +6501,7 @@ int main() {
 getprpwnam()
 ; return 0; }
 EOF
-if { (eval echo configure:6494: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6516: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6499,7 +6521,7 @@ else
   echo "$ac_t""no" 1>&6
 # On DEC, getprpwnam() is in -lsecurity
                    echo $ac_n "checking for getprpwnam in -lsecurity""... $ac_c" 1>&6
-echo "configure:6514: checking for getprpwnam in -lsecurity" >&5
+echo "configure:6536: checking for getprpwnam in -lsecurity" >&5
 ac_lib_var=`echo security'_'getprpwnam | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6507,7 +6529,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsecurity  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6522 "configure"
+#line 6544 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6518,7 +6540,7 @@ int main() {
 getprpwnam()
 ; return 0; }
 EOF
-if { (eval echo configure:6533: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6555: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6545,9 +6567,9 @@ fi
 
   # HP's entry in the "Not Invented Here" Sweepstakes.
   #
-  if test $passwd_cruft_done = no ; then
+  if test "$passwd_cruft_done" = no ; then
     echo $ac_n "checking for HP-style shadow passwords""... $ac_c" 1>&6
-echo "configure:6562: checking for HP-style shadow passwords" >&5
+echo "configure:6584: checking for HP-style shadow passwords" >&5
 if eval "test \"`echo '$''{'ac_cv_hpux_passwd'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6558,7 +6580,7 @@ else
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 6573 "configure"
+#line 6595 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
                                      #include <unistd.h>
@@ -6571,7 +6593,7 @@ struct s_passwd *p = getspwnam("nobody");
                         const char *pw = p->pw_passwd;
 ; return 0; }
 EOF
-if { (eval echo configure:6586: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6608: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_hpux_passwd=yes
 else
@@ -6585,7 +6607,7 @@ rm -f conftest*
 fi
 
 echo "$ac_t""$ac_cv_hpux_passwd" 1>&6
-    if test $ac_cv_hpux_passwd = yes; then
+    if test "$ac_cv_hpux_passwd" = yes; then
       have_shadow=yes
       need_setuid=yes
       passwd_cruft_done=yes
@@ -6596,7 +6618,7 @@ EOF
 
       # on HPUX, bigcrypt is in -lsec
       echo $ac_n "checking for bigcrypt in -lsec""... $ac_c" 1>&6
-echo "configure:6611: checking for bigcrypt in -lsec" >&5
+echo "configure:6633: checking for bigcrypt in -lsec" >&5
 ac_lib_var=`echo sec'_'bigcrypt | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6604,7 +6626,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsec  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6619 "configure"
+#line 6641 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6615,7 +6637,7 @@ int main() {
 bigcrypt()
 ; return 0; }
 EOF
-if { (eval echo configure:6630: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6652: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6640,9 +6662,9 @@ fi
 
   # Traditional (ha!) shadow passwords.
   #
-  if test $passwd_cruft_done = no ; then
+  if test "$passwd_cruft_done" = no ; then
     echo $ac_n "checking for generic shadow passwords""... $ac_c" 1>&6
-echo "configure:6657: checking for generic shadow passwords" >&5
+echo "configure:6679: checking for generic shadow passwords" >&5
 if eval "test \"`echo '$''{'ac_cv_shadow'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6653,7 +6675,7 @@ else
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 6668 "configure"
+#line 6690 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
                                      #include <unistd.h>
@@ -6665,7 +6687,7 @@ struct spwd *p = getspnam("nobody");
                         const char *pw = p->sp_pwdp;
 ; return 0; }
 EOF
-if { (eval echo configure:6680: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6702: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_shadow=yes
 else
@@ -6679,7 +6701,7 @@ rm -f conftest*
 fi
 
 echo "$ac_t""$ac_cv_shadow" 1>&6
-    if test $ac_cv_shadow = yes; then
+    if test "$ac_cv_shadow" = yes; then
       have_shadow=yes
       need_setuid=yes
       passwd_cruft_done=yes
@@ -6691,7 +6713,7 @@ EOF
       # On some systems (UnixWare 2.1), getspnam() is in -lgen instead of -lc.
       have_getspnam=no
       echo $ac_n "checking for getspnam in -lc""... $ac_c" 1>&6
-echo "configure:6706: checking for getspnam in -lc" >&5
+echo "configure:6728: checking for getspnam in -lc" >&5
 ac_lib_var=`echo c'_'getspnam | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6699,7 +6721,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lc  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6714 "configure"
+#line 6736 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6710,7 +6732,7 @@ int main() {
 getspnam()
 ; return 0; }
 EOF
-if { (eval echo configure:6725: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6747: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6730,9 +6752,9 @@ else
   echo "$ac_t""no" 1>&6
 fi
 
-      if test $have_getspnam = no ; then
+      if test "$have_getspnam" = no ; then
         echo $ac_n "checking for getspnam in -lgen""... $ac_c" 1>&6
-echo "configure:6747: checking for getspnam in -lgen" >&5
+echo "configure:6769: checking for getspnam in -lgen" >&5
 ac_lib_var=`echo gen'_'getspnam | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6740,7 +6762,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgen  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6755 "configure"
+#line 6777 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6751,7 +6773,7 @@ int main() {
 getspnam()
 ; return 0; }
 EOF
-if { (eval echo configure:6766: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6788: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6780,9 +6802,9 @@ fi
   # program is setuid.  So, guess that we've got this lossage to contend with
   # if /etc/master.passwd exists, and default to a setuid installation.
   #
-  if test $passwd_cruft_done = no ; then
+  if test "$passwd_cruft_done" = no ; then
     echo $ac_n "checking for FreeBSD-style shadow passwords""... $ac_c" 1>&6
-echo "configure:6797: checking for FreeBSD-style shadow passwords" >&5
+echo "configure:6819: checking for FreeBSD-style shadow passwords" >&5
 if eval "test \"`echo '$''{'ac_cv_master_passwd'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6794,7 +6816,7 @@ else
 fi
 
 echo "$ac_t""$ac_cv_master_passwd" 1>&6
-    if test $ac_cv_master_passwd = yes; then
+    if test "$ac_cv_master_passwd" = yes; then
       need_setuid=yes
       passwd_cruft_done=yes
     fi
@@ -6803,7 +6825,7 @@ echo "$ac_t""$ac_cv_master_passwd" 1>&6
   # On some systems (UnixWare 2.1), crypt() is in -lcrypt instead of -lc.
   have_crypt=no
   echo $ac_n "checking for crypt in -lc""... $ac_c" 1>&6
-echo "configure:6818: checking for crypt in -lc" >&5
+echo "configure:6840: checking for crypt in -lc" >&5
 ac_lib_var=`echo c'_'crypt | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6811,7 +6833,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lc  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6826 "configure"
+#line 6848 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6822,7 +6844,7 @@ int main() {
 crypt()
 ; return 0; }
 EOF
-if { (eval echo configure:6837: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6859: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6842,9 +6864,9 @@ else
   echo "$ac_t""no" 1>&6
 fi
 
-  if test $have_crypt = no ; then
+  if test "$have_crypt" = no ; then
     echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6
-echo "configure:6859: checking for crypt in -lcrypt" >&5
+echo "configure:6881: checking for crypt in -lcrypt" >&5
 ac_lib_var=`echo crypt'_'crypt | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6852,7 +6874,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcrypt  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6867 "configure"
+#line 6889 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6863,7 +6885,7 @@ int main() {
 crypt()
 ; return 0; }
 EOF
-if { (eval echo configure:6878: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6900: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6890,7 +6912,7 @@ fi
   # if they were found.  But, on some systems, we need setuid even when
   # using plain old vanilla passwords.
   #
-  if test $need_setuid = no ; then
+  if test "$need_setuid" = no ; then
     case "$host" in
       *-hpux* | *-aix* | *-netbsd* | *-freebsd* | *-openbsd* )
         need_setuid=yes
@@ -6919,26 +6941,26 @@ DEPEND_DEFINES=
 
 # Done testing things -- now substitute in some stuff for the Makefiles.
 #
-if test $have_motif = yes; then
+if test "$have_motif" = yes; then
   cat >> confdefs.h <<\EOF
 #define HAVE_MOTIF 1
 EOF
 
-  DIALOG_SRCS='$(MOTIF_SRCS)'
-  DIALOG_OBJS='$(MOTIF_OBJS)'
-elif test $have_athena = yes; then
+  TOOLKIT_SRCS='$(MOTIF_SRCS)'
+  TOOLKIT_OBJS='$(MOTIF_OBJS)'
+elif test "$have_athena" = yes; then
   cat >> confdefs.h <<\EOF
 #define HAVE_ATHENA 1
 EOF
 
-  DIALOG_SRCS='$(ATHENA_SRCS)'
-  DIALOG_OBJS='$(ATHENA_OBJS)'
+  TOOLKIT_SRCS='$(ATHENA_SRCS)'
+  TOOLKIT_OBJS='$(ATHENA_OBJS)'
 else
-  DIALOG_SRCS=''
-  DIALOG_OBJS=''
+  TOOLKIT_SRCS=''
+  TOOLKIT_OBJS=''
 fi
 
-if test $have_kerberos = yes; then
+if test "$have_kerberos" = yes; then
   PASSWD_SRCS='$(KERBEROS_SRCS)'
   PASSWD_OBJS='$(KERBEROS_OBJS)'
 else
@@ -6946,7 +6968,7 @@ else
   PASSWD_OBJS='$(PWENT_OBJS)'
 fi
 
-if test $enable_locking = yes; then
+if test "$enable_locking" = yes; then
   LOCK_SRCS='$(LOCK_SRCS_1) $(PASSWD_SRCS)'
   LOCK_OBJS='$(LOCK_OBJS_1) $(PASSWD_OBJS)'
 else
@@ -6954,7 +6976,7 @@ else
   LOCK_OBJS=''
 fi
 
-if test $need_setuid = yes; then
+if test "$need_setuid" = yes; then
   NEED_SETUID=yes
   INSTALL_SETUID='$(INSTALL) $(SUID_FLAGS)'
 else
@@ -6963,13 +6985,11 @@ else
 fi
 
 tab='  '
-if test $have_gl = yes; then
+if test "$have_gl" = yes; then
   GL_EXES='$(GL_EXES)'
-  GL_KLUDGE_1=${tab}${tab}${tab}${tab}${tab}${tab}${tab}${tab}${tab}'  \'
-  GL_KLUDGE_2=${tab}
+  GL_KLUDGE=${tab}
 else
-  GL_KLUDGE_1=${tab}${tab}${tab}${tab}${tab}${tab}${tab}${tab}${tab}'\n'
-  GL_KLUDGE_2='!'${tab}
+  GL_KLUDGE='  -'${tab}
 fi
 
 
@@ -7013,7 +7033,7 @@ warning=no
 warnsep='    #################################################################'
 
 warnpre() {
-  if test $warning = no ; then
+  if test "$warning" = no ; then
     echo '' ; echo "$warnsep" ; echo ''
     warning=yes
   fi
@@ -7021,7 +7041,7 @@ warnpre() {
 
 warn() {
   warnpre
-  if test $warning = long ; then echo '' ; fi
+  if test "$warning" = long ; then echo '' ; fi
   warning=yes
   echo "$warn_prefix $@"
 }
@@ -7030,7 +7050,7 @@ warnL() {
   was=$warning
   warnpre
   warning=yes
-  if test $was != no ; then echo '' ; fi
+  if test "$was" != no ; then echo '' ; fi
   echo "$warn_prefix $@"
 }
 
@@ -7052,49 +7072,50 @@ noteL() {
 }
 
 
-if test $with_sgi_req = yes -a $have_sgi = no ; then
+if test "$with_sgi_req" = yes -a "$have_sgi" = no ; then
   warn 'The SGI saver extension was requested, but was not found.'
 fi
 
-if test $with_mit_req = yes -a $have_mit = no ; then
+if test "$with_mit_req" = yes -a "$have_mit" = no ; then
   warn 'The MIT saver extension was requested, but was not found.'
 fi
 
-if test $with_xidle_req = yes -a $have_xidle = no ; then
+if test "$with_xidle_req" = yes -a "$have_xidle" = no ; then
   warn 'The XIdle extension was requested, but was not found.'
 fi
 
-if test $with_xshm_req = yes -a $have_xshm = no ; then
+if test "$with_xshm_req" = yes -a "$have_xshm" = no ; then
   warn 'The XSHM extension was requested, but was not found.'
 fi
 
-if test $with_sgivc_req = yes -a $have_sgivc = no ; then
+if test "$with_sgivc_req" = yes -a "$have_sgivc" = no ; then
   warn 'The SGI-VIDEO-CONTROL extension was requested, but was not found.'
 fi
 
-if test $with_dpms_req = yes -a $have_dpms = no ; then
+if test "$with_dpms_req" = yes -a "$have_dpms" = no ; then
   warn 'The DPMS extension was requested, but was not found.'
 fi
 
-if test $have_motif = no -a $have_athena = no ; then
+if test "$have_motif" = no -a "$have_athena" = no ; then
   warnL "Neither Motif nor Athena widgets seem to be available;"
-  warn2 "one or the other is required."
+  warn2 "the \`xscreensaver-demo' program requires one or the"
+  warn2 "other."
   proselytize_motif=no
 
-elif test $with_motif_req = yes -a $have_motif = no ; then
+elif test "$with_motif_req" = yes -a "$have_motif" = no ; then
   warnL "Use of Motif was requested, but it wasn't found;"
   warn2 "Athena will be used instead."
 
-elif test $with_athena_req = yes -a $have_athena = no ; then
+elif test "$with_athena_req" = yes -a "$have_athena" = no ; then
   warnL "Use of Athena was requested, but it wasn't found;"
   warn2 "Motif will be used instead."
 fi
 
-if test $have_motif = yes -a $have_lesstif = yes ; then
+if test "$have_motif" = yes -a "$have_lesstif" = yes ; then
 
   preferred_lesstif=0.86
 
-  if test $lesstif_version = unknown; then
+  if test "$lesstif_version" = unknown; then
     warnL "Unable to determine the LessTif version number!"
     warn2 "Make sure you are using version $preferred_lesstif or newer."
     warn2 "See <http://www.lesstif.org/>."
@@ -7108,24 +7129,24 @@ if test $have_motif = yes -a $have_lesstif = yes ; then
   fi
 fi
 
-if test $proselytize_motif = yes ; then
+if test "$proselytize_motif" = yes ; then
     warnL "Athena widgets are being used instead of Motif."
-    warn2 "XScreenSaver looks much better with Motif, and has"
-    warn2 "a few extra features as well.  Wouldn't you rather"
-    warn2 "be using Motif?  It is shipped by every commercial"
-    warn2 "Unix vendor; and there is a free implementation"
-    warn2 "available as well: see <http://www.lesstif.org/>."
+    warn2 "The \`xscreensaver-demo' program looks much better"
+    warn2 "with Motif.  Wouldn't you rather be using Motif?"
+    warn2 "It is shipped by every commercial Unix vendor;"
+    warn2 "and there is a free implementation available as"
+    warn2 "well: see <http://www.lesstif.org/>."
 fi
 
 
-if test $have_gl = yes -a $ac_have_mesa_gl = yes ; then
+if test "$have_gl" = yes -a "$ac_have_mesa_gl" = yes ; then
   preferred_mesagl=2.7
 
-  if test $ac_mesagl_version = unknown; then
+  if test "$ac_mesagl_version" = unknown; then
     warnL "Unable to determine the MesaGL version number!"
     warn2 "Make sure you are using version $preferred_mesagl or newer."
 
-  elif test \! $ac_mesagl_version -gt 2006; then
+  elif test \! "$ac_mesagl_version" -gt 2006; then
     warnL "MesaGL version $ac_mesagl_version_string is being used."
     warn2 "MesaGL versions 2.6 and earlier have a security bug."
     warn2 "It is strongly recommended that you upgrade to at"
@@ -7134,10 +7155,10 @@ if test $have_gl = yes -a $ac_have_mesa_gl = yes ; then
 fi
 
 
-if test $have_xpm = no ; then
-  if test $with_xpm_req = yes ; then
+if test "$have_xpm" = no ; then
+  if test "$with_xpm_req" = yes ; then
     warnL 'Use of XPM was requested, but it was not found.'
-  elif test $with_xpm_req = no ; then
+  elif test "$with_xpm_req" = no ; then
     noteL 'The XPM library is not being used.'
   else
     noteL 'The XPM library was not found.'
@@ -7151,10 +7172,10 @@ if test $have_xpm = no ; then
   warn2 'X11 archive sites, such as <http://sunsite.unc.edu/>.'
 fi
 
-if test $have_gl = no ; then
-  if test $with_gl_req = yes ; then
+if test "$have_gl" = no ; then
+  if test "$with_gl_req" = yes ; then
     warnL 'Use of GL was requested, but it was not found.'
-  elif test $with_gl_req = no ; then
+  elif test "$with_gl_req" = no ; then
     noteL 'The OpenGL 3D library is not being used.'
   else
     noteL 'The OpenGL 3D library was not found.'
@@ -7171,19 +7192,19 @@ if test $have_gl = no ; then
 
 fi
 
-if test $with_readdisplay_req = yes -a $have_readdisplay = no ; then
+if test "$with_readdisplay_req" = yes -a "$have_readdisplay" = no ; then
   warn 'Use of XReadDisplay was requested, but it was not found.'
 fi
 
-if test $with_sgivideo_req = yes -a $have_sgivideo = no ; then
+if test "$with_sgivideo_req" = yes -a "$have_sgivideo" = no ; then
   warn 'Use of the Iris Video Library was requested, but it was not found.'
 fi
 
-if test $with_kerberos_req = yes -a $have_kerberos = no ; then
+if test "$with_kerberos_req" = yes -a "$have_kerberos" = no ; then
   warn 'Use of Kerberos was requested, but it was not found.'
 fi
 
-if test $with_shadow_req = yes -a $have_shadow = no ; then
+if test "$with_shadow_req" = yes -a "$have_shadow" = no ; then
   warn 'Use of shadow passwords was requested, but they were not found.'
 fi
 
@@ -7194,7 +7215,7 @@ if test -n "$with_zippy_req"; then
   fi
 fi
 
-if test $warning != no; then
+if test "$warning" != no; then
   echo '' ; echo "$warnsep" ; echo ''
 fi
 
@@ -7355,6 +7376,7 @@ s%@xemacs_exe@%$xemacs_exe%g
 s%@fortune@%$fortune%g
 s%@INCLUDES@%$INCLUDES%g
 s%@SAVER_LIBS@%$SAVER_LIBS%g
+s%@TOOLKIT_LIBS@%$TOOLKIT_LIBS%g
 s%@HACK_LIBS@%$HACK_LIBS%g
 s%@XPM_LIBS@%$XPM_LIBS%g
 s%@GL_LIBS@%$GL_LIBS%g
@@ -7364,8 +7386,8 @@ s%@INSTALL_DIRS@%$INSTALL_DIRS%g
 s%@NEED_SETUID@%$NEED_SETUID%g
 s%@SGI_VIDEO_OBJS@%$SGI_VIDEO_OBJS%g
 s%@SGI_VIDEO_LIBS@%$SGI_VIDEO_LIBS%g
-s%@DIALOG_SRCS@%$DIALOG_SRCS%g
-s%@DIALOG_OBJS@%$DIALOG_OBJS%g
+s%@TOOLKIT_SRCS@%$TOOLKIT_SRCS%g
+s%@TOOLKIT_OBJS@%$TOOLKIT_OBJS%g
 s%@PASSWD_SRCS@%$PASSWD_SRCS%g
 s%@PASSWD_OBJS@%$PASSWD_OBJS%g
 s%@XMU_SRCS@%$XMU_SRCS%g
@@ -7373,8 +7395,7 @@ s%@XMU_OBJS@%$XMU_OBJS%g
 s%@LOCK_SRCS@%$LOCK_SRCS%g
 s%@LOCK_OBJS@%$LOCK_OBJS%g
 s%@GL_EXES@%$GL_EXES%g
-s%@GL_KLUDGE_1@%$GL_KLUDGE_1%g
-s%@GL_KLUDGE_2@%$GL_KLUDGE_2%g
+s%@GL_KLUDGE@%$GL_KLUDGE%g
 s%@HACKDIR@%$HACKDIR%g
 s%@APPDEFAULTS@%$APPDEFAULTS%g
 s%@DEPEND@%$DEPEND%g
@@ -7624,9 +7645,9 @@ eval HACKDIR=${HACKDIR}
 echo ""
 echo "$warnsep"
 echo ""
-echo '      When you run "make install", the "xscreensaver" and'
-echo '      "xscreensaver-command" executables will be installed in'
-echo "      ${bindir}."
+echo '      When you run "make install", the "xscreensaver",'
+echo '      "xscreensaver-demo", and "xscreensaver-command" executables'
+echo "      will be installed in ${bindir}."
 echo ""
 echo "      The various graphics demos (80+ different executables) will"
 echo "      be installed in ${HACKDIR}."
index d636d21ee0f3e645494c044c7f7858189f313cdc..62495c42e5b00b643c7eeea30d635b9bf9ce64b1 100644 (file)
@@ -2,6 +2,11 @@
 #
 
 AC_INIT(driver/subprocs.c)
+
+echo -n "current directory: "
+pwd
+echo "command line was: $0 $@"
+
 AC_CONFIG_HEADER(config.h)
 AC_CANONICAL_HOST
 
@@ -129,10 +134,10 @@ AC_CACHE_VAL(ac_cv_gettimeofday_args,
                                 [ac_gettimeofday_args=0])])
   ac_cv_gettimeofday_args=$ac_gettimeofday_args])
 ac_gettimeofday_args=$ac_cv_gettimeofday_args
-if test $ac_gettimeofday_args = 1 ; then
+if test "$ac_gettimeofday_args" = 1 ; then
   AC_DEFINE(HAVE_GETTIMEOFDAY)
   AC_MSG_RESULT(one argument)
-elif test $ac_gettimeofday_args = 2 ; then
+elif test "$ac_gettimeofday_args" = 2 ; then
   AC_DEFINE(HAVE_GETTIMEOFDAY)
   AC_DEFINE(GETTIMEOFDAY_TWO_ARGS)
   AC_MSG_RESULT(two arguments)
@@ -142,7 +147,7 @@ fi
 
 
 AC_CHECK_FUNCS(select fcntl uname nice setpriority getcwd getwd putenv)
-AC_CHECK_FUNCS(sigaction)
+AC_CHECK_FUNCS(sigaction syslog)
 
 AC_CHECK_HEADERS(unistd.h crypt.h)
 
@@ -322,19 +327,19 @@ AC_DEFUN(AC_TRY_X_COMPILE, [
 AC_DEFUN(AC_CHECK_X_LIB, [
   ac_save_CPPFLAGS="$CPPFLAGS"
   ac_save_LDFLAGS="$LDFLAGS"
+
   if test \! -z "$includedir" ; then 
     CPPFLAGS="$CPPFLAGS -I$includedir"
   fi
-  if test \! -z "$includedir" ; then 
-    CPPFLAGS="$CPPFLAGS -I$includedir"
-  fi
+  # note: $X_CFLAGS includes $x_includes
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
   if test \! -z "$libdir" ; then
     LDFLAGS="$LDFLAGS -L$libdir"
   fi
-  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  if test \! -z "$x_libraries" ; then
-    LDFLAGS="$LDFLAGS -L$x_libraries"
-  fi
+  # note: $X_LIBS includes $x_libraries
+  LDFLAGS="$LDFLAGS $X_LIBS"
+
   AC_CHECK_LIB([$1], [$2], [$3], [$4], [$5])
   CPPFLAGS="$ac_save_CPPFLAGS"
   LDFLAGS="$ac_save_LDFLAGS"])
@@ -428,7 +433,7 @@ AC_CACHE_CHECK([for XPointer], ac_cv_xpointer,
                                  [XPointer foo = (XPointer) 0;],
                                  [ac_cv_xpointer=yes],
                                  [ac_cv_xpointer=no])])
-if test $ac_cv_xpointer != yes; then
+if test "$ac_cv_xpointer" != yes; then
   AC_DEFINE(XPointer,[char*])
 fi
 
@@ -555,7 +560,7 @@ esac
 #
 have_xmu=no
 AC_CHECK_X_HEADER(X11/Xmu/Error.h, [have_xmu=yes])
-if test $have_xmu = no ; then
+if test "$have_xmu" = no ; then
   XMU_SRCS='$(UTILS_SRC)/xmu.c'
   XMU_OBJS='$(UTILS_BIN)/xmu.o'
 else
@@ -570,7 +575,7 @@ fi
 # See comp.windows.x FAQ question 124 about _get_wmShellWidgetClass on 4.1.x.
 # The right fix is to get OpenWindows 3.0 patches 100512-02 and 100573-03.
 #
-if test $have_xmu = yes ; then
+if test "$have_xmu" = yes ; then
   case "$host" in
     *-sunos4*)
     AC_CACHE_CHECK([for the SunOS 4.1.x _get_wmShellWidgetClass bug],
@@ -587,14 +592,14 @@ if test $have_xmu = yes ; then
                                [ac_cv_sunos_xmu_bug=no],
                                [ac_cv_sunos_xmu_bug=yes])
                    LDFLAGS="$ac_save_LDFLAGS"])
-    if test $ac_cv_sunos_xmu_bug = yes ; then
+    if test "$ac_cv_sunos_xmu_bug" = yes ; then
       AC_CACHE_CHECK([whether the compiler understands -static], 
                     ac_cv_ld_static,
                     [ac_save_LDFLAGS="$LDFLAGS"
                      LDFLAGS="$LDFLAGS -static"
                      AC_TRY_LINK(,,[ac_cv_ld_static=yes],[ac_cv_ld_static=no])
                    LDFLAGS="$ac_save_LDFLAGS"])
-      if test $ac_cv_ld_static = yes ; then
+      if test "$ac_cv_ld_static" = yes ; then
         LDFLAGS="$LDFLAGS -static"
       else
        LDFLAGS="$LDFLAGS -Bstatic"
@@ -624,12 +629,12 @@ X Server Extension options:
 
 HANDLE_X_PATH_ARG(with_sgi, --with-sgi-ext, SGI SCREEN_SAVER)
 
-if test $with_sgi = yes; then
+if test "$with_sgi" = yes; then
   AC_CHECK_X_HEADER(X11/extensions/XScreenSaver.h,
                    [have_sgi=yes
                     AC_DEFINE(HAVE_SGI_SAVER_EXTENSION)])
 
-elif test $with_sgi != no; then
+elif test "$with_sgi" != no; then
   echo "error: must be yes or no: --with-sgi-ext=$with_sgi"
   exit 1
 fi
@@ -647,17 +652,17 @@ AC_ARG_WITH(mit-ext,
 
 HANDLE_X_PATH_ARG(with_mit, --with-mit-ext, MIT-SCREEN-SAVER)
 
-if test $have_sgi != yes; then
-  if test $with_mit = yes; then
+if test "$have_sgi" != yes; then
+  if test "$with_mit" = yes; then
     AC_CHECK_X_HEADER(X11/extensions/scrnsaver.h, [have_mit=yes])
 
     # Now check to see if it's really in the library; XF86Free-3.3 ships
     # scrnsaver.h, but doesn't include the code in libXext.a, the idiots!
     #
-    if test $have_mit = yes; then
+    if test "$have_mit" = yes; then
       AC_CHECK_X_LIB(Xext, XScreenSaverRegister, [], [have_mit=no], -lm)
 
-      if test $have_mit = no; then
+      if test "$have_mit" = no; then
        # Fuck!  Looks like XF86Free-3.3 actually puts it in XExExt instead
        # of in Xext.  Thank you master, may I have another.
         AC_CHECK_X_LIB(XExExt, XScreenSaverRegister,
@@ -665,7 +670,7 @@ if test $have_sgi != yes; then
                       [], -lX11 -lXext -lm)
       fi
 
-      if test $have_mit = no; then
+      if test "$have_mit" = no; then
        # Double fuck!  Looks like some versions of XFree86 (whichever version
        # it is that comes with RedHat Linux 2.0 -- I can't find a version 
        # number) put this garbage in Xss instead of Xext.  Thank you master,
@@ -675,13 +680,13 @@ if test $have_sgi != yes; then
                       [], -lX11 -lXext -lm)
       fi
 
-    if test $have_mit = yes; then
+    if test "$have_mit" = yes; then
       AC_DEFINE(HAVE_MIT_SAVER_EXTENSION)
     fi
 
     fi
 
-  elif test $with_mit != no; then
+  elif test "$with_mit" != no; then
     echo "error: must be yes or no: --with-mit-ext=$with_mit"
     exit 1
   fi
@@ -700,11 +705,11 @@ AC_ARG_WITH(xidle-ext,
 
 HANDLE_X_PATH_ARG(with_xidle, --with-xidle-ext, XIDLE)
 
-if test $with_xidle = yes; then
+if test "$with_xidle" = yes; then
   AC_CHECK_X_HEADER(X11/extensions/xidle.h,
                    [have_xidle=yes
                     AC_DEFINE(HAVE_XIDLE_EXTENSION)])
-elif test $with_xidle != no; then
+elif test "$with_xidle" != no; then
   echo "error: must be yes or no: --with-xidle-ext=$with_xidle"
   exit 1
 fi
@@ -722,19 +727,19 @@ AC_ARG_WITH(xshm-ext,
 
 HANDLE_X_PATH_ARG(with_xshm, --with-xshm-ext, XSHM)
 
-if test $with_xshm = yes; then
+if test "$with_xshm" = yes; then
 
   # first check for Xshm.h.
   AC_CHECK_X_HEADER(X11/extensions/XShm.h, [have_xshm=yes])
 
   # if that succeeded, then check for sys/ipc.h.
-  if test $have_xshm = yes; then
+  if test "$have_xshm" = yes; then
     have_xshm=no
     AC_CHECK_X_HEADER(sys/ipc.h, [have_xshm=yes])
   fi
 
   # if that succeeded, then check for sys/shm.h.
-  if test $have_xshm = yes; then
+  if test "$have_xshm" = yes; then
     have_xshm=no
     AC_CHECK_X_HEADER(sys/shm.h, [have_xshm=yes])
   fi
@@ -754,11 +759,11 @@ if test $with_xshm = yes; then
   esac
 
   # if that succeeded, then we've really got it.
-  if test $have_xshm = yes; then
+  if test "$have_xshm" = yes; then
     AC_DEFINE(HAVE_XSHM_EXTENSION)
   fi
 
-elif test $with_xshm != no; then
+elif test "$with_xshm" != no; then
   echo "error: must be yes or no: --with-xshm-ext=$with_xshm"
   exit 1
 fi
@@ -776,13 +781,13 @@ AC_ARG_WITH(sgivc-ext,
 
 HANDLE_X_PATH_ARG(with_sgivc, --with-sgivc-ext, SGI-VIDEO-CONTROL)
 
-if test $with_sgivc = yes; then
+if test "$with_sgivc" = yes; then
 
   # first check for XSGIvc.h
   AC_CHECK_X_HEADER(X11/extensions/XSGIvc.h, [have_sgivc=yes])
 
   # if that succeeded, then check for the -lXsgivc
-  if test $have_sgivc = yes; then
+  if test "$have_sgivc" = yes; then
     have_sgivc=no
     AC_CHECK_X_LIB(Xsgivc, XSGIvcQueryGammaMap,
                  [have_sgivc=yes; SAVER_LIBS="$SAVER_LIBS -lXsgivc"], [],
@@ -790,11 +795,11 @@ if test $with_sgivc = yes; then
   fi
 
   # if that succeeded, then we've really got it.
-  if test $have_sgivc = yes; then
+  if test "$have_sgivc" = yes; then
     AC_DEFINE(HAVE_SGI_VC_EXTENSION)
   fi
 
-elif test $with_sgivc != no; then
+elif test "$with_sgivc" != no; then
   echo "error: must be yes or no: --with-sgivc-ext=$with_sgivc"
   exit 1
 fi
@@ -812,13 +817,13 @@ AC_ARG_WITH(dpms-ext,
 
 HANDLE_X_PATH_ARG(with_dpms, --with-dpms-ext, DPMS)
 
-if test $with_dpms = yes; then
+if test "$with_dpms" = yes; then
 
   # first check for dpms.h
   AC_CHECK_X_HEADER(X11/extensions/dpms.h, [have_dpms=yes])
 
   # if that succeeded, then check for the -lXdpms
-  if test $have_dpms = yes; then
+  if test "$have_dpms" = yes; then
     have_dpms=no
     AC_CHECK_X_LIB(Xdpms, DPMSInfo,
                  [have_dpms=yes; SAVER_LIBS="$SAVER_LIBS -lXdpms"], [],
@@ -826,11 +831,11 @@ if test $with_dpms = yes; then
   fi
 
   # if that succeeded, then we've really got it.
-  if test $have_dpms = yes; then
+  if test "$have_dpms" = yes; then
     AC_DEFINE(HAVE_DPMS_EXTENSION)
   fi
 
-elif test $with_dpms != no; then
+elif test "$with_dpms" != no; then
   echo "error: must be yes or no: --with-dpms-ext=$with_dpms"
   exit 1
 fi
@@ -863,25 +868,25 @@ AC_ARG_WITH(athena,
 
 HANDLE_X_PATH_ARG(with_athena, --with-athena, Athena)
 
-if test $with_motif != yes -a $with_motif != no ; then
+if test "$with_motif" != yes -a "$with_motif" != no ; then
   echo "error: must be yes or no: --with-motif=$with_motif"
   exit 1
 fi
 
-if test $with_athena != yes -a $with_athena != no ; then
+if test "$with_athena" != yes -a "$with_athena" != no ; then
   echo "error: must be yes or no: --with-athena=$with_athena"
   exit 1
 fi
 
 
 # Saying --without-motif is the same as saying --with-athena.
-if test $with_motif_req = no ; then
+if test "$with_motif_req" = no ; then
   with_athena_req=yes
   with_athena=yes
 fi
 
 # Saying --without-athena is the same as saying --with-motif.
-if test $with_athena_req = no ; then
+if test "$with_athena_req" = no ; then
   with_motif_req=yes
   with_motif=yes
 fi
@@ -892,21 +897,23 @@ check_motif() {
   AC_CHECK_X_HEADER(Xm/Xm.h,
                    [have_motif=yes
                     AC_DEFINE(HAVE_MOTIF)
-                    SAVER_LIBS="-lXm $SAVER_LIBS"])
+                    TOOLKIT_LIBS="-lXm $TOOLKIT_LIBS"])
 }
 
 check_athena() {
   have_athena=no
   have_athena3d=no
   AC_CHECK_X_HEADER(X11/Xaw/Dialog.h, [have_athena=yes])
-  AC_CHECK_X_LIB(Xaw3d, Xaw3dComputeTopShadowRGB,
-                [have_athena=yes; have_athena3d=yes], [],
-                -lXt -lXmu -lXext -lX11)
-
-  if test $have_athena3d = yes; then
-    SAVER_LIBS="-lXaw3d $SAVER_LIBS"
-  elif test $have_athena = yes; then
-    SAVER_LIBS="-lXaw $SAVER_LIBS"
+  if test "$have_athena" = yes; then
+    AC_CHECK_X_LIB(Xaw3d, Xaw3dComputeTopShadowRGB,
+                  [have_athena=yes; have_athena3d=yes], [],
+                  -lXt -lXmu -lXext -lX11)
+  fi
+
+  if test "$have_athena3d" = yes; then
+    TOOLKIT_LIBS="-lXaw3d $TOOLKIT_LIBS"
+  elif test "$have_athena" = yes; then
+    TOOLKIT_LIBS="-lXaw $TOOLKIT_LIBS"
   fi
 }
 
@@ -917,20 +924,20 @@ check_athena() {
 # If they asked for neither, check motif then athena.
 
 proselytize_motif=yes
-if test $with_motif = yes; then
+if test "$with_motif" = yes; then
   # asked for both, or for motif only
   check_motif
-  if test $have_motif = yes; then
+  if test "$have_motif" = yes; then
     with_athena=no
     with_athena_req=no
   else
     check_athena
   fi
 
-elif test $with_athena = yes; then
+elif test "$with_athena" = yes; then
   # asked for athena only
   check_athena
-  if test $have_athena = yes; then
+  if test "$have_athena" = yes; then
     with_motif=no
     proselytize_motif=no
   else
@@ -940,7 +947,7 @@ elif test $with_athena = yes; then
 else
   # asked for neither
   check_motif
-  if test $have_motif = yes; then
+  if test "$have_motif" = yes; then
     with_athena=no
   else
     check_athena
@@ -948,20 +955,20 @@ else
 
 fi
 
-if test $have_motif = yes; then
+if test "$have_motif" = yes; then
   proselytize_motif=no
 fi
 
 # If we have Athena, check whether it's a version that includes
 # XawViewportSetCoordinates in Viewport.h (R3 (or R4?) don't.)
-if test $have_athena = yes ; then
+if test "$have_athena" = yes ; then
   AC_CACHE_CHECK([for XawViewportSetCoordinates in Viewport.h], 
                 ac_cv_have_XawViewportSetCoordinates,
                 [ac_cv_have_XawViewportSetCoordinates=no
                  AC_EGREP_X_HEADER(XawViewportSetCoordinates, 
                                    X11/Xaw/Viewport.h,
                                    ac_cv_have_XawViewportSetCoordinates=yes)])
-  if test $ac_cv_have_XawViewportSetCoordinates = yes ; then
+  if test "$ac_cv_have_XawViewportSetCoordinates" = yes ; then
     AC_DEFINE(HAVE_XawViewportSetCoordinates)
   fi
 fi
@@ -970,7 +977,7 @@ fi
 # If we have Motif, check whether it's really LessTif.
 #
 have_lesstif=no
-if test $have_motif = yes ; then
+if test "$have_motif" = yes ; then
   AC_CACHE_CHECK([whether Motif is really LessTif], 
                 ac_cv_have_lesstif,
                 [AC_TRY_X_COMPILE([#include <Xm/Xm.h>],
@@ -987,7 +994,7 @@ unset ac_cv_lesstif_version_string
 lesstif_version=unknown
 lesstif_version_string=unknown
 
-if test $have_lesstif = yes ; then
+if test "$have_lesstif" = yes ; then
   ltv=unknown
   echo unknown > conftest-lt
   AC_CACHE_CHECK([LessTif version number],
@@ -1021,10 +1028,10 @@ fi
 # I have no idea.
 #
 have_xp_ext=no
-if test $have_motif = yes ; then
+if test "$have_motif" = yes ; then
    have_xp_ext=no
    AC_CHECK_X_LIB(Xp, XpQueryExtension,
-                 [have_xp_ext=yes; SAVER_LIBS="$SAVER_LIBS -lXp"],
+                 [have_xp_ext=yes; TOOLKIT_LIBS="$TOOLKIT_LIBS -lXp"],
                  [], -lX11 -lXext -lm)
 fi
 
@@ -1043,12 +1050,12 @@ Graphics Demo options:
 
 HANDLE_X_PATH_ARG(with_xpm, --with-xpm, XPM)
 
-if test $with_xpm = yes; then
+if test "$with_xpm" = yes; then
   AC_CHECK_X_HEADER(X11/xpm.h,
                   [have_xpm=yes
                    AC_DEFINE(HAVE_XPM)
                    XPM_LIBS="-lXpm"])
-elif test $with_xpm != no; then
+elif test "$with_xpm" != no; then
   echo "error: must be yes or no: --with-xpm=$with_xpm"
   exit 1
 fi
@@ -1070,15 +1077,15 @@ HANDLE_X_PATH_ARG(with_gl, --with-gl, GL)
 ac_mesagl_version=unknown
 ac_mesagl_version_string=unknown
 
-if test $with_gl = yes; then
+if test "$with_gl" = yes; then
   AC_CHECK_X_HEADER(GL/gl.h, have_gl=yes, have_gl=no)
-  if test $have_gl = yes ; then
+  if test "$have_gl" = yes ; then
     AC_CHECK_X_HEADER(GL/glx.h, have_gl=yes, have_gl=no)
   fi
 
   # If we have the headers, try and figure out which vendor it's from.
   #
-  if test $have_gl = yes ; then
+  if test "$have_gl" = yes ; then
 
     AC_DEFINE(HAVE_GL)
 
@@ -1093,7 +1100,7 @@ if test $with_gl = yes; then
     ac_have_mesa_gl=$ac_cv_have_mesa_gl
     AC_MSG_RESULT($ac_have_mesa_gl)
 
-    if test $ac_have_mesa_gl = no ; then
+    if test "$ac_have_mesa_gl" = no ; then
       gl_lib_1="GL"
       GL_LIBS="-lGL -lGLU"
     else
@@ -1106,7 +1113,7 @@ if test $with_gl = yes; then
     # If it's MesaGL, we'd like to issue a warning if the version number
     # is less than or equal to 2.6, because that version had a security bug.
     #
-    if test $ac_have_mesa_gl = yes; then
+    if test "$ac_have_mesa_gl" = yes; then
 
       # don't cache these.
       unset ac_cv_mesagl_version
@@ -1121,8 +1128,18 @@ if test $with_gl = yes; then
 #configure: MESA_MAJOR_VERSION MESA_MINOR_VERSION
 EOF
 
+        ac_save_CPPFLAGS="$CPPFLAGS"
+        if test \! -z "$includedir" ; then 
+          CPPFLAGS="$CPPFLAGS -I$includedir"
+        fi
+        CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
         mglv=`(eval "$ac_cpp conftest.$ac_ext") 2>&AC_FD_CC | sed -n \
              's/^#configure:.*\([0-9][0-9]*\).*\([0-9][0-9]*\).*$/\1.\2/p'`
+         rm -f conftest.$ac_ext
+
+        CPPFLAGS="$ac_save_CPPFLAGS"
+
         if test "$mglv" = ""; then
            ac_mesagl_version=unknown
            ac_mesagl_version_string=unknown
@@ -1131,6 +1148,10 @@ EOF
            maj=`echo $mglv | sed -n 's/\..*//p'`
            min=`echo $mglv | sed -n 's/.*\.//p'`
            ac_mesagl_version=`echo "$maj * 1000 + $min" | bc`
+           if test -z "$ac_mesagl_version"; then
+            ac_mesagl_version=unknown
+             ac_mesagl_version_string=unknown
+          fi
          fi
          ac_cv_mesagl_version=$ac_mesagl_version
          ac_cv_mesagl_version_string=$ac_mesagl_version_string
@@ -1148,7 +1169,7 @@ EOF
 
   fi
 
-elif test $with_gl != no; then
+elif test "$with_gl" != no; then
   echo "error: must be yes or no: --with-gl=$with_gl"
   exit 1
 fi
@@ -1167,10 +1188,10 @@ AC_ARG_WITH(readdisplay,
 
 HANDLE_X_PATH_ARG(with_readdisplay, --with-readdisplay, XReadDisplay)
 
-if test $with_readdisplay = yes; then
+if test "$with_readdisplay" = yes; then
   AC_CHECK_X_HEADER(X11/extensions/readdisplay.h,
                    AC_DEFINE(HAVE_READ_DISPLAY_EXTENSION))
-elif test $with_readdisplay != no; then
+elif test "$with_readdisplay" != no; then
   echo "error: must be yes or no: --with-readdisplay=$with_readdisplay"
   exit 1
 fi
@@ -1189,18 +1210,18 @@ AC_ARG_WITH(sgivideo,
 
 HANDLE_X_PATH_ARG(with_sgivideo, --with-sgivideo, Iris Video)
 
-if test $with_sgivideo = yes; then
+if test "$with_sgivideo" = yes; then
   AC_CHECK_X_HEADER(dmedia/vl.h, have_sgivideo=yes)
-  if test $have_sgivideo = yes; then
+  if test "$have_sgivideo" = yes; then
     have_sgivideo=no
     AC_CHECK_LIB(vl, vlOpenVideo, have_sgivideo=yes)
-    if test $have_sgivideo = yes; then
+    if test "$have_sgivideo" = yes; then
       SGI_VIDEO_OBJS="$(UTILS_BIN)/sgivideo.o"
       SGI_VIDEO_LIBS="-lvl"
       AC_DEFINE(HAVE_SGI_VIDEO)
     fi
   fi
-elif test $with_sgivideo != no; then
+elif test "$with_sgivideo" != no; then
   echo "error: must be yes or no: --with-sgivideo=$with_sgivideo"
   exit 1
 fi
@@ -1281,7 +1302,7 @@ if test ! -n "$ac_cv_zippy_program"; then
     #
     # try running libexec/yow and see if it exits without error.
     #
-    if test x"$dir" != x -a -x $dir/yow ; then
+    if test x"$dir" != x -a -x "$dir/yow" ; then
       if $dir/yow >&- 2>&- ; then
        ac_cv_zippy_program="$dir/yow"
        AC_MSG_RESULT($ac_cv_zippy_program)
@@ -1303,7 +1324,7 @@ if test ! -n "$ac_cv_zippy_program"; then
       #
       # try running libexec/yow and see if it exits without error.
       #
-      if test x"$dir" != x -a -x $dir/yow ; then
+      if test x"$dir" != x -a -x "$dir/yow" ; then
         if $dir/yow >&- 2>&- ; then
          ac_cv_zippy_program="$dir/yow"
          AC_MSG_RESULT($ac_cv_zippy_program)
@@ -1366,9 +1387,9 @@ Screen Locking options:
                           (this is the default.)
   --disable-locking       Do not allow locking at all.],
   [enable_locking="$enableval"],[enable_locking=yes])
-if test $enable_locking = yes; then
+if test "$enable_locking" = yes; then
   true
-elif test $enable_locking = no; then
+elif test "$enable_locking" = no; then
   AC_DEFINE(NO_LOCKING)
 else
   echo "error: must be yes or no: --enable-locking=$enable_locking"
@@ -1388,9 +1409,9 @@ AC_ARG_ENABLE(vt-locking,[
   --disable-vt-locking    Do not allow locking of VTs, even if locking is
                           enabled.],
   [enable_vt_locking="$enableval"],[enable_vt_locking=yes])
-if test $enable_vt_locking = yes; then
+if test "$enable_vt_locking" = yes; then
 
-  AC_MSG_CHECKING(for VT_LOCKSWITCH ioctl)
+  AC_MSG_CHECKING(for the VT_LOCKSWITCH ioctl)
   AC_CACHE_VAL(ac_cv_vt_lockswitch,
    [AC_TRY_COMPILE([#include <fcntl.h>
                    #include <sys/ioctl.h>
@@ -1401,22 +1422,23 @@ if test $enable_vt_locking = yes; then
   ac_vt_lockswitch=$ac_cv_vt_lockswitch
   AC_MSG_RESULT($ac_vt_lockswitch)
 
-elif test $enable_locking = no; then
+elif test "$enable_locking" = no; then
   true
 else
   echo "error: must be yes or no: --enable-vt-locking=$enable_vt_locking"
   exit 1
 fi
 
-if test $ac_vt_lockswitch = yes; then
+if test "$ac_vt_lockswitch" = yes; then
   AC_DEFINE(HAVE_VT_LOCKSWITCH)
   # the VT_LOCKSWITCH ioctl can only be used when running as root.
-  need_setuid=yes
+  # #### but it doesn't work yet, so don't worry about that for now.
+#  need_setuid=yes
 fi
 
 
 
-if test $enable_locking = yes; then
+if test "$enable_locking" = yes; then
 
   # Check for Kerberos.
   #
@@ -1428,12 +1450,12 @@ if test $enable_locking = yes; then
 
   HANDLE_X_PATH_ARG(with_kerberos, --with-kerberos, Kerberos)
 
-  if test $with_kerberos = yes; then
+  if test "$with_kerberos" = yes; then
     AC_CACHE_CHECK([for Kerberos], ac_cv_kerberos,
                   [AC_TRY_X_COMPILE([#include <krb.h>],,
                                     [ac_cv_kerberos=yes],
                                     [ac_cv_kerberos=no])])
-    if test $ac_cv_kerberos = yes ; then
+    if test "$ac_cv_kerberos" = yes ; then
       have_kerberos=yes
       AC_DEFINE(HAVE_KERBEROS)
 
@@ -1445,7 +1467,7 @@ if test $enable_locking = yes; then
        ))
 
     fi
-  elif test $with_kerberos != no; then
+  elif test "$with_kerberos" != no; then
     echo "error: must be yes or no: --with-kerberos=$with_kerberos"
     exit 1
   fi
@@ -1462,9 +1484,9 @@ if test $enable_locking = yes; then
 
   HANDLE_X_PATH_ARG(with_shadow, --with-shadow, shadow password)
 
-  if test $with_shadow = no; then
+  if test "$with_shadow" = no; then
     passwd_cruft_done=yes
-  elif test $with_shadow != yes; then
+  elif test "$with_shadow" != yes; then
     echo "error: must be yes or no: --with-shadow=$with_shadow"
     exit 1
   fi
@@ -1472,7 +1494,7 @@ if test $enable_locking = yes; then
 
   # Sun's "adjunct" passwords.
   #
-  if test $passwd_cruft_done = no ; then
+  if test "$passwd_cruft_done" = no ; then
     AC_CACHE_CHECK([for Sun-style shadow passwords], ac_cv_sun_adjunct,
                   [AC_TRY_X_COMPILE([#include <stdlib.h>
                                      #include <unistd.h>
@@ -1484,7 +1506,7 @@ if test $enable_locking = yes; then
                         const char *pw = p->pwa_passwd;],
                        [ac_cv_sun_adjunct=yes],
                        [ac_cv_sun_adjunct=no])])
-    if test $ac_cv_sun_adjunct = yes; then
+    if test "$ac_cv_sun_adjunct" = yes; then
       have_shadow=yes
       need_setuid=yes
       passwd_cruft_done=yes
@@ -1494,7 +1516,7 @@ if test $enable_locking = yes; then
 
   # DEC and SCO so-called "enhanced" security.
   #
-  if test $passwd_cruft_done = no ; then
+  if test "$passwd_cruft_done" = no ; then
     AC_CACHE_CHECK([for DEC-style shadow passwords], ac_cv_enhanced_passwd,
                   [AC_TRY_X_COMPILE([#include <stdlib.h>
                                      #include <unistd.h>
@@ -1529,7 +1551,7 @@ if test $enable_locking = yes; then
 
   # HP's entry in the "Not Invented Here" Sweepstakes.
   #
-  if test $passwd_cruft_done = no ; then
+  if test "$passwd_cruft_done" = no ; then
     AC_CACHE_CHECK([for HP-style shadow passwords], ac_cv_hpux_passwd,
                   [AC_TRY_X_COMPILE([#include <stdlib.h>
                                      #include <unistd.h>
@@ -1541,7 +1563,7 @@ if test $enable_locking = yes; then
                         const char *pw = p->pw_passwd;],
                        [ac_cv_hpux_passwd=yes],
                        [ac_cv_hpux_passwd=no])])
-    if test $ac_cv_hpux_passwd = yes; then
+    if test "$ac_cv_hpux_passwd" = yes; then
       have_shadow=yes
       need_setuid=yes
       passwd_cruft_done=yes
@@ -1554,7 +1576,7 @@ if test $enable_locking = yes; then
 
   # Traditional (ha!) shadow passwords.
   #
-  if test $passwd_cruft_done = no ; then
+  if test "$passwd_cruft_done" = no ; then
     AC_CACHE_CHECK([for generic shadow passwords], ac_cv_shadow,
                   [AC_TRY_X_COMPILE([#include <stdlib.h>
                                      #include <unistd.h>
@@ -1565,7 +1587,7 @@ if test $enable_locking = yes; then
                         const char *pw = p->sp_pwdp;],
                        [ac_cv_shadow=yes],
                        [ac_cv_shadow=no])])
-    if test $ac_cv_shadow = yes; then
+    if test "$ac_cv_shadow" = yes; then
       have_shadow=yes
       need_setuid=yes
       passwd_cruft_done=yes
@@ -1574,7 +1596,7 @@ if test $enable_locking = yes; then
       # On some systems (UnixWare 2.1), getspnam() is in -lgen instead of -lc.
       have_getspnam=no
       AC_CHECK_LIB(c, getspnam, [have_getspnam=yes])
-      if test $have_getspnam = no ; then
+      if test "$have_getspnam" = no ; then
         AC_CHECK_LIB(gen, getspnam,
                     [have_getspnam=yes; PASSWD_LIBS="$PASSWD_LIBS -lgen"])
       fi
@@ -1586,14 +1608,14 @@ if test $enable_locking = yes; then
   # program is setuid.  So, guess that we've got this lossage to contend with
   # if /etc/master.passwd exists, and default to a setuid installation.
   #
-  if test $passwd_cruft_done = no ; then
+  if test "$passwd_cruft_done" = no ; then
     AC_CACHE_CHECK([for FreeBSD-style shadow passwords], ac_cv_master_passwd,
                   [if test -f /etc/master.passwd ; then
                      ac_cv_master_passwd=yes
                    else
                      ac_cv_master_passwd=no
                    fi])
-    if test $ac_cv_master_passwd = yes; then
+    if test "$ac_cv_master_passwd" = yes; then
       need_setuid=yes
       passwd_cruft_done=yes
     fi
@@ -1602,7 +1624,7 @@ if test $enable_locking = yes; then
   # On some systems (UnixWare 2.1), crypt() is in -lcrypt instead of -lc.
   have_crypt=no
   AC_CHECK_LIB(c, crypt, [have_crypt=yes])
-  if test $have_crypt = no ; then
+  if test "$have_crypt" = no ; then
     AC_CHECK_LIB(crypt, crypt,
                 [have_crypt=yes; PASSWD_LIBS="$PASSWD_LIBS -lcrypt"])
   fi
@@ -1612,7 +1634,7 @@ if test $enable_locking = yes; then
   # if they were found.  But, on some systems, we need setuid even when
   # using plain old vanilla passwords.
   #
-  if test $need_setuid = no ; then
+  if test "$need_setuid" = no ; then
     case "$host" in
       *-hpux* | *-aix* | *-netbsd* | *-freebsd* | *-openbsd* )
         need_setuid=yes
@@ -1641,20 +1663,20 @@ DEPEND_DEFINES=
 
 # Done testing things -- now substitute in some stuff for the Makefiles.
 #
-if test $have_motif = yes; then
+if test "$have_motif" = yes; then
   AC_DEFINE(HAVE_MOTIF)
-  DIALOG_SRCS='$(MOTIF_SRCS)'
-  DIALOG_OBJS='$(MOTIF_OBJS)'
-elif test $have_athena = yes; then
+  TOOLKIT_SRCS='$(MOTIF_SRCS)'
+  TOOLKIT_OBJS='$(MOTIF_OBJS)'
+elif test "$have_athena" = yes; then
   AC_DEFINE(HAVE_ATHENA)
-  DIALOG_SRCS='$(ATHENA_SRCS)'
-  DIALOG_OBJS='$(ATHENA_OBJS)'
+  TOOLKIT_SRCS='$(ATHENA_SRCS)'
+  TOOLKIT_OBJS='$(ATHENA_OBJS)'
 else
-  DIALOG_SRCS=''
-  DIALOG_OBJS=''
+  TOOLKIT_SRCS=''
+  TOOLKIT_OBJS=''
 fi
 
-if test $have_kerberos = yes; then
+if test "$have_kerberos" = yes; then
   PASSWD_SRCS='$(KERBEROS_SRCS)'
   PASSWD_OBJS='$(KERBEROS_OBJS)'
 else
@@ -1662,7 +1684,7 @@ else
   PASSWD_OBJS='$(PWENT_OBJS)'
 fi
 
-if test $enable_locking = yes; then
+if test "$enable_locking" = yes; then
   LOCK_SRCS='$(LOCK_SRCS_1) $(PASSWD_SRCS)'
   LOCK_OBJS='$(LOCK_OBJS_1) $(PASSWD_OBJS)'
 else
@@ -1670,7 +1692,7 @@ else
   LOCK_OBJS=''
 fi
 
-if test $need_setuid = yes; then
+if test "$need_setuid" = yes; then
   NEED_SETUID=yes
   INSTALL_SETUID='$(INSTALL) $(SUID_FLAGS)'
 else
@@ -1679,18 +1701,17 @@ else
 fi
 
 tab='  '
-if test $have_gl = yes; then
+if test "$have_gl" = yes; then
   GL_EXES='$(GL_EXES)'
-  GL_KLUDGE_1=${tab}${tab}${tab}${tab}${tab}${tab}${tab}${tab}${tab}'  \'
-  GL_KLUDGE_2=${tab}
+  GL_KLUDGE=${tab}
 else
-  GL_KLUDGE_1=${tab}${tab}${tab}${tab}${tab}${tab}${tab}${tab}${tab}'\n'
-  GL_KLUDGE_2='!'${tab}
+  GL_KLUDGE='  -'${tab}
 fi
 
 AC_SUBST(INCLUDES)
 
 AC_SUBST(SAVER_LIBS)
+AC_SUBST(TOOLKIT_LIBS)
 AC_SUBST(HACK_LIBS)
 AC_SUBST(XPM_LIBS)
 AC_SUBST(GL_LIBS)
@@ -1701,8 +1722,8 @@ AC_SUBST(NEED_SETUID)
 AC_SUBST(SGI_VIDEO_OBJS)
 AC_SUBST(SGI_VIDEO_LIBS)
 
-AC_SUBST(DIALOG_SRCS)
-AC_SUBST(DIALOG_OBJS)
+AC_SUBST(TOOLKIT_SRCS)
+AC_SUBST(TOOLKIT_OBJS)
 AC_SUBST(PASSWD_SRCS)
 AC_SUBST(PASSWD_OBJS)
 AC_SUBST(XMU_SRCS)
@@ -1710,8 +1731,7 @@ AC_SUBST(XMU_OBJS)
 AC_SUBST(LOCK_SRCS)
 AC_SUBST(LOCK_OBJS)
 AC_SUBST(GL_EXES)
-AC_SUBST(GL_KLUDGE_1)
-AC_SUBST(GL_KLUDGE_2)
+AC_SUBST(GL_KLUDGE)
 AC_SUBST(HACKDIR)
 AC_SUBST(APPDEFAULTS)
 
@@ -1729,7 +1749,7 @@ warning=no
 warnsep='    #################################################################'
 
 warnpre() {
-  if test $warning = no ; then
+  if test "$warning" = no ; then
     echo '' ; echo "$warnsep" ; echo ''
     warning=yes
   fi
@@ -1737,7 +1757,7 @@ warnpre() {
 
 warn() {
   warnpre
-  if test $warning = long ; then echo '' ; fi
+  if test "$warning" = long ; then echo '' ; fi
   warning=yes
   echo "$warn_prefix $@"
 }
@@ -1746,7 +1766,7 @@ warnL() {
   was=$warning
   warnpre
   warning=yes
-  if test $was != no ; then echo '' ; fi
+  if test "$was" != no ; then echo '' ; fi
   echo "$warn_prefix $@"
 }
 
@@ -1768,49 +1788,50 @@ noteL() {
 }
 
 
-if test $with_sgi_req = yes -a $have_sgi = no ; then
+if test "$with_sgi_req" = yes -a "$have_sgi" = no ; then
   warn 'The SGI saver extension was requested, but was not found.'
 fi
 
-if test $with_mit_req = yes -a $have_mit = no ; then
+if test "$with_mit_req" = yes -a "$have_mit" = no ; then
   warn 'The MIT saver extension was requested, but was not found.'
 fi
 
-if test $with_xidle_req = yes -a $have_xidle = no ; then
+if test "$with_xidle_req" = yes -a "$have_xidle" = no ; then
   warn 'The XIdle extension was requested, but was not found.'
 fi
 
-if test $with_xshm_req = yes -a $have_xshm = no ; then
+if test "$with_xshm_req" = yes -a "$have_xshm" = no ; then
   warn 'The XSHM extension was requested, but was not found.'
 fi
 
-if test $with_sgivc_req = yes -a $have_sgivc = no ; then
+if test "$with_sgivc_req" = yes -a "$have_sgivc" = no ; then
   warn 'The SGI-VIDEO-CONTROL extension was requested, but was not found.'
 fi
 
-if test $with_dpms_req = yes -a $have_dpms = no ; then
+if test "$with_dpms_req" = yes -a "$have_dpms" = no ; then
   warn 'The DPMS extension was requested, but was not found.'
 fi
 
-if test $have_motif = no -a $have_athena = no ; then
+if test "$have_motif" = no -a "$have_athena" = no ; then
   warnL "Neither Motif nor Athena widgets seem to be available;"
-  warn2 "one or the other is required."
+  warn2 "the \`xscreensaver-demo' program requires one or the"
+  warn2 "other."
   proselytize_motif=no
 
-elif test $with_motif_req = yes -a $have_motif = no ; then
+elif test "$with_motif_req" = yes -a "$have_motif" = no ; then
   warnL "Use of Motif was requested, but it wasn't found;"
   warn2 "Athena will be used instead."
 
-elif test $with_athena_req = yes -a $have_athena = no ; then
+elif test "$with_athena_req" = yes -a "$have_athena" = no ; then
   warnL "Use of Athena was requested, but it wasn't found;"
   warn2 "Motif will be used instead."
 fi
 
-if test $have_motif = yes -a $have_lesstif = yes ; then
+if test "$have_motif" = yes -a "$have_lesstif" = yes ; then
 
   preferred_lesstif=0.86
 
-  if test $lesstif_version = unknown; then
+  if test "$lesstif_version" = unknown; then
     warnL "Unable to determine the LessTif version number!"
     warn2 "Make sure you are using version $preferred_lesstif or newer."
     warn2 "See <http://www.lesstif.org/>."
@@ -1824,24 +1845,24 @@ if test $have_motif = yes -a $have_lesstif = yes ; then
   fi
 fi
 
-if test $proselytize_motif = yes ; then
+if test "$proselytize_motif" = yes ; then
     warnL "Athena widgets are being used instead of Motif."
-    warn2 "XScreenSaver looks much better with Motif, and has"
-    warn2 "a few extra features as well.  Wouldn't you rather"
-    warn2 "be using Motif?  It is shipped by every commercial"
-    warn2 "Unix vendor; and there is a free implementation"
-    warn2 "available as well: see <http://www.lesstif.org/>."
+    warn2 "The \`xscreensaver-demo' program looks much better"
+    warn2 "with Motif.  Wouldn't you rather be using Motif?"
+    warn2 "It is shipped by every commercial Unix vendor;"
+    warn2 "and there is a free implementation available as"
+    warn2 "well: see <http://www.lesstif.org/>."
 fi
 
 
-if test $have_gl = yes -a $ac_have_mesa_gl = yes ; then
+if test "$have_gl" = yes -a "$ac_have_mesa_gl" = yes ; then
   preferred_mesagl=2.7
 
-  if test $ac_mesagl_version = unknown; then
+  if test "$ac_mesagl_version" = unknown; then
     warnL "Unable to determine the MesaGL version number!"
     warn2 "Make sure you are using version $preferred_mesagl or newer."
 
-  elif test \! $ac_mesagl_version -gt 2006; then
+  elif test \! "$ac_mesagl_version" -gt 2006; then
     warnL "MesaGL version $ac_mesagl_version_string is being used."
     warn2 "MesaGL versions 2.6 and earlier have a security bug."
     warn2 "It is strongly recommended that you upgrade to at"
@@ -1850,10 +1871,10 @@ if test $have_gl = yes -a $ac_have_mesa_gl = yes ; then
 fi
 
 
-if test $have_xpm = no ; then
-  if test $with_xpm_req = yes ; then
+if test "$have_xpm" = no ; then
+  if test "$with_xpm_req" = yes ; then
     warnL 'Use of XPM was requested, but it was not found.'
-  elif test $with_xpm_req = no ; then
+  elif test "$with_xpm_req" = no ; then
     noteL 'The XPM library is not being used.'
   else
     noteL 'The XPM library was not found.'
@@ -1867,10 +1888,10 @@ if test $have_xpm = no ; then
   warn2 'X11 archive sites, such as <http://sunsite.unc.edu/>.'
 fi
 
-if test $have_gl = no ; then
-  if test $with_gl_req = yes ; then
+if test "$have_gl" = no ; then
+  if test "$with_gl_req" = yes ; then
     warnL 'Use of GL was requested, but it was not found.'
-  elif test $with_gl_req = no ; then
+  elif test "$with_gl_req" = no ; then
     noteL 'The OpenGL 3D library is not being used.'
   else
     noteL 'The OpenGL 3D library was not found.'
@@ -1887,19 +1908,19 @@ if test $have_gl = no ; then
 
 fi
 
-if test $with_readdisplay_req = yes -a $have_readdisplay = no ; then
+if test "$with_readdisplay_req" = yes -a "$have_readdisplay" = no ; then
   warn 'Use of XReadDisplay was requested, but it was not found.'
 fi
 
-if test $with_sgivideo_req = yes -a $have_sgivideo = no ; then
+if test "$with_sgivideo_req" = yes -a "$have_sgivideo" = no ; then
   warn 'Use of the Iris Video Library was requested, but it was not found.'
 fi
 
-if test $with_kerberos_req = yes -a $have_kerberos = no ; then
+if test "$with_kerberos_req" = yes -a "$have_kerberos" = no ; then
   warn 'Use of Kerberos was requested, but it was not found.'
 fi
 
-if test $with_shadow_req = yes -a $have_shadow = no ; then
+if test "$with_shadow_req" = yes -a "$have_shadow" = no ; then
   warn 'Use of shadow passwords was requested, but they were not found.'
 fi
 
@@ -1910,7 +1931,7 @@ if test -n "$with_zippy_req"; then
   fi
 fi
 
-if test $warning != no; then
+if test "$warning" != no; then
   echo '' ; echo "$warnsep" ; echo ''
 fi
 
@@ -1941,9 +1962,9 @@ eval HACKDIR=${HACKDIR}
 echo ""
 echo "$warnsep"
 echo ""
-echo '      When you run "make install", the "xscreensaver" and'
-echo '      "xscreensaver-command" executables will be installed in'
-echo "      ${bindir}."
+echo '      When you run "make install", the "xscreensaver",'
+echo '      "xscreensaver-demo", and "xscreensaver-command" executables'
+echo "      will be installed in ${bindir}."
 echo ""
 echo "      The various graphics demos (80+ different executables) will"
 echo "      be installed in ${HACKDIR}."
index 148883d73d70dc1ec562a9b2d9939f96703fdffe..a5ad371204de185e7fe654359852a7b95f837489 100644 (file)
@@ -61,7 +61,6 @@ UTILS_BIN     = ../utils
 
 INCLUDES       = -I. -I$(srcdir) -I$(UTILS_SRC) -I.. @INCLUDES@
 
-PASSWD_LIBS    = @PASSWD_LIBS@
 MOTIF_SRCS     = dialogs-Xm.c
 MOTIF_OBJS     = dialogs-Xm.o
 
@@ -79,47 +78,67 @@ LOCK_OBJS_1 = lock.o
 
 TEST_SRCS      = test-passwd.c test-uid.c test-xdpms.c
 
-DIALOG_SRCS    = @DIALOG_SRCS@
-DIALOG_OBJS    = @DIALOG_OBJS@
+TOOLKIT_SRCS   = @TOOLKIT_SRCS@
+TOOLKIT_OBJS   = @TOOLKIT_OBJS@
+TOOLKIT_LIBS   = @TOOLKIT_LIBS@
+
 PASSWD_SRCS    = @PASSWD_SRCS@
 PASSWD_OBJS    = @PASSWD_OBJS@
+PASSWD_LIBS    = @PASSWD_LIBS@
+
 LOCK_SRCS      = @LOCK_SRCS@
 LOCK_OBJS      = @LOCK_OBJS@
 
-UTIL_SRCS      = $(UTILS_SRC)/fade.c $(UTILS_SRC)/overlay.c \
+SAVER_UTIL_SRCS        = $(UTILS_SRC)/fade.c $(UTILS_SRC)/overlay.c \
                  $(UTILS_SRC)/resources.c $(UTILS_SRC)/usleep.c \
                  $(UTILS_SRC)/visual.c $(UTILS_SRC)/xroger.c \
-                 $(UTILS_SRC)/spline.c \
-                 $(UTILS_SRC)/yarandom.c @XMU_SRCS@
-UTIL_OBJS      = $(UTILS_BIN)/fade.o $(UTILS_BIN)/overlay.o \
+                 $(UTILS_SRC)/spline.c $(UTILS_SRC)/yarandom.c
+SAVER_UTIL_OBJS        = $(UTILS_BIN)/fade.o $(UTILS_BIN)/overlay.o \
                  $(UTILS_BIN)/resources.o $(UTILS_BIN)/usleep.o \
                  $(UTILS_BIN)/visual.o $(UTILS_BIN)/xroger.o \
-                 $(UTILS_BIN)/spline.o \
-                 $(UTILS_BIN)/yarandom.o @XMU_OBJS@
+                 $(UTILS_BIN)/spline.o $(UTILS_BIN)/yarandom.o
+
+DEMO_UTIL_SRCS = $(UTILS_SRC)/resources.c $(UTILS_SRC)/usleep.c \
+                 $(UTILS_SRC)/visual.c
+DEMO_UTIL_OBJS = $(UTILS_BIN)/resources.o $(UTILS_BIN)/usleep.o \
+                 $(UTILS_BIN)/visual.o
+
+SAVER_SRCS_1   = xscreensaver.c windows.c timers.c subprocs.c \
+                 xset.c splash.c setuid.c stderr.c
+SAVER_OBJS_1   = xscreensaver.o windows.o timers.o subprocs.o \
+                 xset.o splash.o setuid.o stderr.o
+
+SAVER_SRCS     = $(SAVER_SRCS_1) prefs.c $(LOCK_SRCS) \
+                 $(SAVER_UTIL_SRCS) @XMU_SRCS@
+SAVER_OBJS     = $(SAVER_OBJS_1) prefs.o $(LOCK_OBJS) \
+                 $(SAVER_UTIL_OBJS) @XMU_OBJS@
 
-SAVER_SRCS_1   = demo.c stderr.c subprocs.c setuid.c timers.c windows.c \
-                 xscreensaver.c splash.c xset.c dotfile.c
-SAVER_OBJS_1   = demo.o stderr.o subprocs.o setuid.o timers.o windows.o \
-                 xscreensaver.o splash.o xset.o dotfile.o
+CMD_SRCS       = remote.c xscreensaver-command.c
+CMD_OBJS       = remote.o xscreensaver-command.o
 
-SAVER_SRCS     = $(SAVER_SRCS_1) $(DIALOG_SRCS) $(LOCK_SRCS) $(UTIL_SRCS)
-SAVER_OBJS     = $(SAVER_OBJS_1) $(DIALOG_OBJS) $(LOCK_OBJS) $(UTIL_OBJS)
+DEMO_SRCS_1    = demo.c prefs.c
+DEMO_OBJS_1    = demo.o prefs.o
 
-CMD_SRCS       = xscreensaver-command.c
-CMD_OBJS       = xscreensaver-command.o
+DEMO_SRCS      = $(DEMO_SRCS_1) remote.c \
+                 $(TOOLKIT_SRCS) $(DEMO_UTIL_SRCS)
+DEMO_OBJS      = $(DEMO_OBJS_1) remote.o \
+                 $(TOOLKIT_OBJS) $(DEMO_UTIL_OBJS)
 
 SAVER_LIBS     = $(LIBS) $(X_LIBS) @SAVER_LIBS@ \
                  $(X_PRE_LIBS) -lXt -lX11 -lXext $(X_EXTRA_LIBS) \
                  $(PASSWD_LIBS)
 
-CMD_LIBS       = $(X_LIBS) $(X_PRE_LIBS)      \
-                 -lX11 -lXext $(X_EXTRA_LIBS) \
-                 $(LIBS)
+CMD_LIBS       = $(LIBS) $(X_LIBS) \
+                 $(X_PRE_LIBS) -lX11 -lXext $(X_EXTRA_LIBS)
 
-EXES           = xscreensaver xscreensaver-command
+DEMO_LIBS      = $(LIBS) $(X_LIBS) $(TOOLKIT_LIBS) \
+                 $(X_PRE_LIBS) -lXt -lX11 -lXext $(X_EXTRA_LIBS)
 
-HDRS           = XScreenSaver_ad.h xscreensaver.h
-MEN            = xscreensaver.man xscreensaver-command.man
+EXES           = xscreensaver xscreensaver-command xscreensaver-demo
+
+HDRS           = XScreenSaver_ad.h xscreensaver.h prefs.h remote.h
+MEN            = xscreensaver.man xscreensaver-demo.man \
+                 xscreensaver-command.man
 EXTRAS         = README Makefile.in XScreenSaver.ad.in dialogs.xd .gdbinit
 VMSFILES       = compile_axp.com compile_decc.com link_axp.com link_decc.com \
                  vms-getpwnam.c vms-pwd.h vms-hpwd.c vms-validate.c \
@@ -127,7 +146,8 @@ VMSFILES    = compile_axp.com compile_decc.com link_axp.com link_decc.com \
 
 TARFILES       = $(EXTRAS) $(VMSFILES) $(SAVER_SRCS_1) \
                  $(MOTIF_SRCS) $(ATHENA_SRCS) $(PWENT_SRCS) $(KERBEROS_SRCS) \
-                 $(LOCK_SRCS_1) $(CMD_SRCS) $(HDRS) $(TEST_SRCS) $(MEN)
+                 $(LOCK_SRCS_1) $(DEMO_SRCS_1) $(CMD_SRCS) $(HDRS) \
+                 $(TEST_SRCS) $(MEN)
 
 
 all: $(EXES)
@@ -157,13 +177,14 @@ install-program: $(EXES)
  $$e "           must run 'make install' as 'root', not as '$$me'."         ;\
  $$e ""                                                                             ;\
  $$e "           For now, xscreensaver will be installed non-setuid, which"  ;\
- $$e "           means that locking might not work."                        ;\
+ $$e "           means that locking might not work.  (Try it and see.)"             ;\
  $$e ""                                                                             ;\
           fi ;                                                         \
        fi ;                                                            \
        echo $$inst xscreensaver $(bindir)/xscreensaver ;               \
        $$inst xscreensaver $(bindir)/xscreensaver
        $(INSTALL_PROGRAM) xscreensaver-command $(bindir)/xscreensaver-command
+       $(INSTALL_PROGRAM) xscreensaver-demo $(bindir)/xscreensaver-demo
 
 install-ad: XScreenSaver.ad
        @if [ ! -d $(AD_DIR) ]; then $(INSTALL_DIRS) $(AD_DIR) ; fi
@@ -218,7 +239,7 @@ distdepend: update_ad_version update_man_version XScreenSaver_ad.h
        -s '# DO NOT DELETE: updated by make distdepend' $(DEPEND_FLAGS) -- \
        $(INCLUDES) $(DEFS) $(DEPEND_DEFINES) $(CFLAGS) $(X_CFLAGS) --      \
        $(SAVER_SRCS_1) $(MOTIF_SRCS) $(ATHENA_SRCS) $(PWENT_SRCS)          \
-       $(LOCK_SRCS_1) $(CMD_SRCS) |                                        \
+       $(LOCK_SRCS_1) $(DEMO_SRCS_1) $(CMD_SRCS) $(TEST_SRCS) |            \
        (                                                                   \
          awk '/^# .*Makefile.in ---/,/^# DO .*distdepend/' < Makefile.in ; \
          sed -e 's@ \./@ @g;s@ /[^ ]*@@g;/^.*:$$/d'                        \
@@ -319,9 +340,13 @@ xscreensaver: $(SAVER_OBJS)
 xscreensaver-command: $(CMD_OBJS)
        $(CC) $(LDFLAGS) -o $@ $(CMD_OBJS) $(CMD_LIBS)
 
+xscreensaver-demo: $(DEMO_OBJS)
+       $(CC) $(LDFLAGS) -o $@ $(DEMO_OBJS) $(DEMO_LIBS)
+
 
-TEST_PASSWD_OBJS = test-passwd.o $(LOCK_OBJS_1) $(PWENT_OBJS) $(DIALOG_OBJS) \
-        subprocs.o setuid.o demo.o splash.o \
+
+TEST_PASSWD_OBJS = test-passwd.o $(LOCK_OBJS_1) $(PWENT_OBJS) $(TOOLKIT_OBJS) \
+        subprocs.o setuid.o demo.o splash.o prefs.o \
        $(UTIL_OBJS)
 test-passwd.o: XScreenSaver_ad.h
 
@@ -334,44 +359,68 @@ test-uid: test-uid.o
 test-xdpms: test-xdpms.o
        $(CC) $(LDFLAGS) -o $@ test-xdpms.o $(SAVER_LIBS)
 
+
+# This kludge is so that I can build/test the Athena version of the
+# xscreensaver-demo program without having to re-run configure.
+# Normally it builds it with Motif if possible; this lets me build
+# both.
+#
+xscreensaver-demo-Xaw: $(ATHENA_OBJS) demo-Xaw.o $(DEMO_OBJS)
+       $(CC) $(LDFLAGS) -o $@ demo-Xaw.o prefs.o remote.o \
+               $(ATHENA_OBJS) $(DEMO_UTIL_OBJS) \
+               $(LIBS) $(X_LIBS) -lXaw \
+               $(X_PRE_LIBS) -lXt -lX11 -lXext $(X_EXTRA_LIBS)
+xscreensaver-demo-Xaw3d: $(ATHENA_OBJS) demo-Xaw.o $(DEMO_OBJS)
+       $(CC) $(LDFLAGS) -o $@ demo-Xaw.o prefs.o remote.o \
+               $(ATHENA_OBJS) $(DEMO_UTIL_OBJS) \
+               $(LIBS) $(X_LIBS) -lXaw3d \
+               $(X_PRE_LIBS) -lXt -lX11 -lXext $(X_EXTRA_LIBS)
+demo-Xaw.o: demo.c XScreenSaver_ad.h
+       $(CC) -o $@ -c -DHAVE_ATHENA_KLUDGE \
+       $(INCLUDES) $(DEFS2) $(CFLAGS) $(X_CFLAGS) $<
+
+
+
 ##############################################################################
 #
 # DO NOT DELETE: updated by make distdepend
 # $(srcdir)/DO $(srcdir)/NOT $(srcdir)/DELETE: $(srcdir)/updated $(srcdir)/by $(srcdir)/make $(srcdir)/distdepend
 
-demo.o: ../config.h
-demo.o: $(srcdir)/xscreensaver.h
-demo.o: $(UTILS_SRC)/resources.h
-stderr.o: ../config.h
-stderr.o: $(srcdir)/xscreensaver.h
-stderr.o: $(UTILS_SRC)/resources.h
-stderr.o: $(UTILS_SRC)/visual.h
-subprocs.o: ../config.h
-subprocs.o: $(srcdir)/xscreensaver.h
-subprocs.o: $(UTILS_SRC)/yarandom.h
-setuid.o: ../config.h
-setuid.o: $(srcdir)/xscreensaver.h
-timers.o: ../config.h
-timers.o: $(srcdir)/xscreensaver.h
-windows.o: ../config.h
-windows.o: $(srcdir)/xscreensaver.h
-windows.o: $(UTILS_SRC)/visual.h
-windows.o: $(UTILS_SRC)/fade.h
 xscreensaver.o: ../config.h
 xscreensaver.o: $(srcdir)/xscreensaver.h
+xscreensaver.o: $(srcdir)/prefs.h
 xscreensaver.o: $(UTILS_SRC)/version.h
 xscreensaver.o: $(UTILS_SRC)/yarandom.h
 xscreensaver.o: $(UTILS_SRC)/resources.h
 xscreensaver.o: $(UTILS_SRC)/visual.h
 xscreensaver.o: XScreenSaver_ad.h
+windows.o: ../config.h
+windows.o: $(srcdir)/xscreensaver.h
+windows.o: $(srcdir)/prefs.h
+windows.o: $(UTILS_SRC)/visual.h
+windows.o: $(UTILS_SRC)/fade.h
+timers.o: ../config.h
+timers.o: $(srcdir)/xscreensaver.h
+timers.o: $(srcdir)/prefs.h
+subprocs.o: ../config.h
+subprocs.o: $(srcdir)/xscreensaver.h
+subprocs.o: $(srcdir)/prefs.h
+subprocs.o: $(UTILS_SRC)/yarandom.h
+xset.o: ../config.h
+xset.o: $(srcdir)/xscreensaver.h
+xset.o: $(srcdir)/prefs.h
 splash.o: ../config.h
 splash.o: $(srcdir)/xscreensaver.h
+splash.o: $(srcdir)/prefs.h
 splash.o: $(UTILS_SRC)/resources.h
-xset.o: ../config.h
-xset.o: $(srcdir)/xscreensaver.h
-dotfile.o: ../config.h
-dotfile.o: $(srcdir)/xscreensaver.h
-dotfile.o: $(UTILS_SRC)/resources.h
+setuid.o: ../config.h
+setuid.o: $(srcdir)/xscreensaver.h
+setuid.o: $(srcdir)/prefs.h
+stderr.o: ../config.h
+stderr.o: $(srcdir)/xscreensaver.h
+stderr.o: $(srcdir)/prefs.h
+stderr.o: $(UTILS_SRC)/resources.h
+stderr.o: $(UTILS_SRC)/visual.h
 dialogs-Xm.o: ../config.h
 dialogs-Xm.o: $(UTILS_SRC)/visual.h
 dialogs-Xaw.o: ../config.h
@@ -379,7 +428,29 @@ dialogs-Xaw.o: $(UTILS_SRC)/visual.h
 passwd.o: ../config.h
 lock.o: ../config.h
 lock.o: $(srcdir)/xscreensaver.h
+lock.o: $(srcdir)/prefs.h
 lock.o: $(UTILS_SRC)/resources.h
+demo.o: ../config.h
+demo.o: $(UTILS_SRC)/version.h
+demo.o: $(srcdir)/prefs.h
+demo.o: $(UTILS_SRC)/resources.h
+demo.o: $(UTILS_SRC)/visual.h
+demo.o: $(srcdir)/remote.h
+demo.o: XScreenSaver_ad.h
+prefs.o: ../config.h
+prefs.o: $(srcdir)/prefs.h
+prefs.o: $(UTILS_SRC)/resources.h
+remote.o: ../config.h
+remote.o: $(srcdir)/remote.h
 xscreensaver-command.o: ../config.h
+xscreensaver-command.o: $(srcdir)/remote.h
 xscreensaver-command.o: $(UTILS_SRC)/version.h
+test-passwd.o: ../config.h
+test-passwd.o: $(srcdir)/xscreensaver.h
+test-passwd.o: $(srcdir)/prefs.h
+test-passwd.o: $(UTILS_SRC)/resources.h
+test-passwd.o: $(UTILS_SRC)/version.h
+test-passwd.o: XScreenSaver_ad.h
+test-uid.o: ../config.h
+test-xdpms.o: ../config.h
 
index daec6ff40e568bd46587279a720ec95077d9d998..ba06bb857a231f9065be0a47f79a09ec162c06e6 100644 (file)
@@ -4,12 +4,19 @@
 !            a screen saver and locker for the X window system
 !                            by Jamie Zawinski
 !
-!                              version 2.34
-!                                08-Oct-98
+!                              version 3.01
+!                                24-Oct-98
 !
 ! See "man xscreensaver" for more info.  The latest version is always
 ! available at http://www.jwz.org/xscreensaver/
 
+
+! These resources, when placed in the system-wide app-defaults directory
+! (e.g., /usr/lib/X11/app-defaults/XScreenSaver) will provide the default
+! settings for new users.  However, if you have a ".xscreensaver" file in
+! your home directory, the settings in that file take precedence.
+
+
 *timeout:              10
 *cycle:                        10
 *lockTimeout:          0
 *overlayStderr:                True
 *font:                 *-medium-r-*-140-*-m-*
 
+! This is what the "Demo" button on the splash screen runs (/bin/sh syntax.)
+*demoCommand: xscreensaver-demo
+
+! This is what the "Prefs" button on the splash screen runs (/bin/sh syntax.)
+*prefsCommand: xscreensaver-demo -prefs
+
 ! This is the URL that the "Help" button on the splash screen loads.
 *helpURL: http://www.jwz.org/xscreensaver/man.html
 
-! This is how the "Help" button loads URLs (in /bin/sh syntax.)
-*loadURL: netscape -remote 'openURL(%s)' || netscape '%s' &
+! This is how the "Help" button loads URLs (/bin/sh syntax.)
+! The "helpURL" will be substituted for up to two occurrences of "%s".
+*loadURL: netscape -remote 'openURL(%s)' || netscape '%s'
 
 
 ! Turning on "installColormap" interacts erratically with twm and tvtwm,
 !
 ! Each line is an `sh' command.
 !
-! But, if the first word on the line is the name of a visual followed by a
+! If the first (non-blank) character on the line is "-", then that means
+! that this command is disabled: it's still in the list, but it won't ever
+! be used.  (This is just to make it easy to disable and then re-enable 
+! them later.)
+!
+! If the first word on the line is the name of a visual followed by a
 ! colon, then that visual will be used for the program, if it is available.
 ! If no such visual is available, then the program will be skipped.  In
 ! this way, you can specify that you want certain programs to run only
                jigsaw -root                                            \n\
                blitspin -root -grab                                    \n\
                slip -root                                              \n\
+               distort -root                                           \n\
                hypercube -root                                         \n\
                halo -root                                              \n\
                maze -root                                              \n\
                vines -root                                             \n\
                kaleidescope -root                                      \n\
                xjack -root                                             \n\
+  -            xlyap -root -randomize                                  \n\
                cynosure -root                                          \n\
                flow -root                                              \n\
                epicycle -root                                          \n\
                crystal -root                                           \n\
                discrete -root                                          \n\
                kumppa -root                                            \n\
+               rd-bomb -root                                           \n\
+               rd-bomb -root -speed 1 -size 0.1                        \n\
                                                                          \
        mono:   rocks -root                                             \n\
        color:  rocks -root -fg darksalmon                              \n\
        color:  attraction -root -glow -points 10                       \n\
        color:  bubbles -root                                           \n\
                                                                          \
-        color:  rd-bomb -root                                          \n\
-        color:  rd-bomb -root -speed 1 -size 0.1                       \n\
-                                                                         \
   PseudoColor: qix -root -count 4 -solid -transparent                  \n\
   PseudoColor: qix -root -count 5 -solid -transparent -linear            \
                        -segments 250 -size 100                         \n\
-@GL_KLUDGE_1@
-@GL_KLUDGE_2@  gears -root                                             \n\
-@GL_KLUDGE_2@  superquadrics -root                                     \n\
-@GL_KLUDGE_2@  morph3d -root                                           \n\
-@GL_KLUDGE_2@  cage -root                                              \n\
-@GL_KLUDGE_2@  moebius -root                                           \n\
-@GL_KLUDGE_2@  stairs -root                                            \n\
-@GL_KLUDGE_2@  pipes -root                                             \n\
-@GL_KLUDGE_2@  sproingies -root                                        \n\
-@GL_KLUDGE_2@  rubik -root                                             \n\
-@GL_KLUDGE_2@  atlantis -root                                          \n\
-@GL_KLUDGE_2@  lament -root                                            \n\
-@GL_KLUDGE_2@  bubble3d -root                                          \n\
-@GL_KLUDGE_2@  glplanet -root                                          \n
+                                                                         \
+@GL_KLUDGE@    gears -root                                             \n\
+@GL_KLUDGE@    superquadrics -root                                     \n\
+@GL_KLUDGE@    morph3d -root                                           \n\
+@GL_KLUDGE@    cage -root                                              \n\
+@GL_KLUDGE@    moebius -root                                           \n\
+@GL_KLUDGE@    stairs -root                                            \n\
+@GL_KLUDGE@    pipes -root                                             \n\
+@GL_KLUDGE@    sproingies -root                                        \n\
+@GL_KLUDGE@    rubik -root                                             \n\
+@GL_KLUDGE@    atlantis -root                                          \n\
+@GL_KLUDGE@    lament -root                                            \n\
+@GL_KLUDGE@    bubble3d -root                                          \n\
+@GL_KLUDGE@    glplanet -root                                          \n
  
 
 ! A few of the hacks require OpenGL, and will only be built if you have it.
 !=============================================================================
 
 
-! Resources for the password and splash-screen dialog boxes.
+XScreenSaver.pointerPollTime:          5
+XScreenSaver.initialDelay:             0
+XScreenSaver.windowCreationTimeout:    30
+XScreenSaver.bourneShell:              /bin/sh
+
+
+! Resources for the password and splash-screen dialog boxes of
+! the "xscreensaver" daemon.
 !
 *Dialog.headingFont:           *-times-bold-r-*-*-*-180-*-*-*-iso8859-1
 *Dialog.bodyFont:              *-helvetica-bold-r-*-*-*-140-*-*-*-iso8859-1
 *splash.help.label:            Help
 
 
-! Resources for the Motif dialog boxes:
+! Resources for the Motif dialog boxes of the "xscreensaver-demo" program.
 ! 
 *fontList:                       *-helvetica-medium-r-*-*-*-120-*-*-*-iso8859-1
 *demoDialog*label1.fontList:     *-helvetica-medium-r-*-*-*-140-*-*-*-iso8859-1
 *XmTextField.fontList:             *-courier-medium-r-*-*-*-120-*-*-*-iso8859-1
-*splashDialog*fontList:                   *-helvetica-bold-r-*-*-*-120-*-*-*-iso8859-1
-*splashDialog*splashLabel1.fontList:   *-times-bold-r-*-*-*-180-*-*-*-iso8859-1
-*splashDialog*splashLabel2.fontList:   *-times-bold-r-*-*-*-140-*-*-*-iso8859-1
-*splashDialog*splashLabel3.fontList:   *-times-bold-r-*-*-*-140-*-*-*-iso8859-1
+*label0.fontList:                  *-helvetica-bold-r-*-*-*-140-*-*-*-iso8859-1
 XScreenSaver*XmList.fontList:      *-courier-medium-r-*-*-*-120-*-*-*-iso8859-1
 ! Need to fully-qualify the preceeding in the case of of *sgiMode.
 
@@ -338,11 +362,10 @@ XScreenSaver*XmList.fontList:      *-courier-medium-r-*-*-*-120-*-*-*-iso8859-1
 *XmDialogShell*demoList.foreground:    #000000
 *XmDialogShell*demoList.background:    #FFFFFF
 
-! Need to fully-qualify the following in the case of of *sgiMode.
-XScreenSaver*XmDialogShell*rogerLabel.foreground:      #CD0000
-XScreenSaver*XmDialogShell*rogerLabel.background:      #FFFFFF
-
 *XmDialogShell.title:          XScreenSaver
+*versionWarning_popup.title:   XScreenSaver Warning
+*demoForm_popup.title:         XScreenSaver Demo
+*preferencesForm_popup.title:  XScreenSaver Preferences
 *allowShellResize:             True
 *autoUnmanage:                 False
 
@@ -358,10 +381,10 @@ XScreenSaver*XmDialogShell*rogerLabel.background: #FFFFFF
 *next.labelString:             Run Next
 *prev.labelString:             Run Previous
 *edit.labelString:             Preferences
-*done.labelString:             Exit Demo Mode
 *restart.labelString:          Reinitialize
+*done.labelString:             Quit
 
-*resourcesLabel.labelString:   XScreenSaver Parameters
+*preferencesLabel.labelString: XScreenSaver Parameters
 
 *timeoutLabel.labelString:     Saver Timeout
 *cycleLabel.labelString:       Cycle Timeout
@@ -369,53 +392,50 @@ XScreenSaver*XmDialogShell*rogerLabel.background: #FFFFFF
 *fadeTicksLabel.labelString:   Fade Ticks
 *lockLabel.labelString:                Lock Timeout
 *passwdLabel.labelString:      Password Timeout
-*resourcesForm*XmTextField.columns:    8
+*preferencesForm*XmTextField.columns:  8
 
 *verboseToggle.labelString:    Verbose
 *cmapToggle.labelString:       Install Colormap
 *fadeToggle.labelString:       Fade Colormap
 *unfadeToggle.labelString:     Unfade Colormap
 *lockToggle.labelString:       Require Password
-*resourcesDone.labelString:    OK
-*resourcesCancel.labelString:  Cancel
-
-*splashDialog.title:           XScreenSaver
-*splashLabel1.labelString:     XScreenSaver %s
-*splashLabel2.labelString:     Copyright Â© 1991-1998 by
-*splashLabel3.labelString:     Jamie Zawinski <jwz@jwz.org>
-*splashDemo.labelString:       Demo
-*splashPrefs.labelString:      Prefs
-*splashDialog*Help.labelString:        Help
-
-*splashLabel1.alignment:       ALIGNMENT_CENTER
-*splashLabel2.alignment:       ALIGNMENT_CENTER
-*splashLabel3.alignment:       ALIGNMENT_CENTER
+*preferencesDone.labelString:  OK
+*preferencesCancel.labelString:        Cancel
 
-*splashDialog.borderWidth:     1
-*splashForm.shadowThickness:   4
 
 ! Disable Motif drag-and-drop in dialog boxes.  This is kind of pathetic, but
 ! in some older versions of Motif, most any attempt to drag cause immediate
 ! flaming death from above.  This *should* rip the legs off that bug.
+! (But sadly, Lesstif 0.86 and earlier ignore these resources *and* have
+! buggy drag-and-drop.)
 !
 XScreenSaver*dragInitiatorProtocolStyle: DRAG_NONE
 XScreenSaver*dragReceiverProtocolStyle:  DRAG_NONE
 
 
 
-! Resources for the dialog boxes using the abominable Athena widgets:
+! Resources for the Athena dialog boxes of the "xscreensaver-demo" program.
 ! 
+*demo_dialog.title:            XScreenSaver Demo
+*preferences_dialog.title:     XScreenSaver Preferences
+*warning_dialog.title:         XScreenSaver Warning
+
+! For some reason, it doesn't size correctly by itself.
+*demo_dialog.geometry:         =640x400
+
 *demo_dialog*font:             *-helvetica-bold-r-*-*-*-120-*-*-*-iso8859-1
-*resources_dialog*font:                *-helvetica-bold-r-*-*-*-120-*-*-*-iso8859-1
-*splash_dialog*font:           *-helvetica-bold-r-*-*-*-140-*-*-*-iso8859-1
-*splash_dialog*splashLabel1.font:   *-times-bold-r-*-*-*-180-*-*-*-iso8859-1
-*splash_dialog*splashLabel2.font:   *-times-bold-r-*-*-*-140-*-*-*-iso8859-1
-*splash_dialog*splashLabel3.font:   *-times-bold-r-*-*-*-140-*-*-*-iso8859-1
+*preferences_dialog*font:      *-helvetica-bold-r-*-*-*-120-*-*-*-iso8859-1
 *demo_dialog*label1.font:      *-helvetica-bold-r-*-*-*-140-*-*-*-iso8859-1
-*resources_dialog*label1.font: *-helvetica-bold-r-*-*-*-140-*-*-*-iso8859-1
-XScreenSaver.demo_dialog*List.font: \
+*preferences_dialog*label1.font:*-helvetica-bold-r-*-*-*-140-*-*-*-iso8859-1
+XScreenSaver*warning_dialog*label0.font:       \
+                               *-helvetica-bold-r-*-*-*-140-*-*-*-iso8859-1
+XScreenSaver*warning_dialog*Label.font:        \
+                               *-helvetica-bold-r-*-*-*-120-*-*-*-iso8859-1
+XScreenSaver*warning_dialog*Command.font: \
+                               *-helvetica-bold-r-*-*-*-140-*-*-*-iso8859-1
+XScreenSaver.demo_dialog*List.font:    \
                                *-courier-medium-r-*-*-*-120-*-*-*-iso8859-1
-XScreenSaver.demo_dialog*Text*font: \
+XScreenSaver.demo_dialog*Text*font:    \
                                *-courier-medium-r-*-*-*-120-*-*-*-iso8859-1
 
 XScreenSaver.demo_dialog*foreground:                   #000000
@@ -425,76 +445,63 @@ XScreenSaver.demo_dialog*Scrollbar.background:            #D9D9D9
 XScreenSaver.demo_dialog*Command.background:           #D9D9D9
 XScreenSaver.demo_dialog*Text*background:              #FFFFFF
 
-XScreenSaver.resources_dialog*foreground:              #000000
-XScreenSaver.resources_dialog*background:              #E5E5E5
-XScreenSaver.resources_dialog*Command.background:      #D9D9D9
-XScreenSaver.resources_dialog*Toggle.background:       #D9D9D9
-XScreenSaver.resources_dialog*Text*background:         #FFFFFF
+XScreenSaver.preferences_dialog*foreground:            #000000
+XScreenSaver.preferences_dialog*background:            #E5E5E5
+XScreenSaver.preferences_dialog*Command.background:    #D9D9D9
+XScreenSaver.preferences_dialog*Toggle.background:     #D9D9D9
+XScreenSaver.preferences_dialog*Text*background:       #FFFFFF
 
-*resources_dialog*Dialog.value.translations: #override\n\
-       <Key>Return: beginning-of-line()\n
+XScreenSaver.warning_dialog*foreground:                        #000000
+XScreenSaver.warning_dialog*background:                        #E5E5E5
+XScreenSaver.warning_dialog*Command.background:                #D9D9D9
 
-XScreenSaver.splash_dialog*foreground:                 #000000
-XScreenSaver.splash_dialog*background:                 #E5E5E5
-XScreenSaver.splash_dialog*Command.background:         #D9D9D9
-XScreenSaver.splash_dialog*Text*background:            #FFFFFF
-XScreenSaver.splash_dialog*roger.foreground:           #CD0000
-XScreenSaver.splash_dialog*roger.background:           #FFFFFF
+*preferences_dialog*Dialog.value.translations: #override\n\
+       <Key>Return: beginning-of-line()\n
 
 *demo_dialog*viewport.height:                  200
 *Form.borderWidth:                             0
 *Box.borderWidth:                              0
 *Label.borderWidth:                            0
-*resources_dialog*Dialog.borderWidth:          0
+*preferences_dialog*Dialog.borderWidth:                0
 
 *demo_dialog*next.label:                       Run Next
 *demo_dialog*prev.label:                       Run Previous
 *demo_dialog*edit.label:                       Preferences
-*demo_dialog*done.label:                       Exit Demo Mode
 *demo_dialog*restart.label:                    Reinitialize
+*demo_dialog*done.label:                       Quit
 XScreenSaver.demo_dialog*Command.internalWidth:  10
 XScreenSaver.demo_dialog*Command.internalHeight: 4
 
-*resources_dialog*timeout.label:               Saver Timeout:
-*resources_dialog*cycle.label:                 Cycle Timeout:
-*resources_dialog*fade.label:                  Fade Duration:
-*resources_dialog*ticks.label:                 Fade Ticks:
-*resources_dialog*lockTime.label:              Lock Timeout:
-*resources_dialog*passwdTime.label:            Password Timeout:
-
-*resources_dialog*label1.label:                        XScreenSaver Parameters
-*resources_dialog*buttonbox.verbose.label:     Verbose
-*resources_dialog*buttonbox.cmap.label:                Install Colormap
-*resources_dialog*buttonbox.fade.label:                Fade Colormap
-*resources_dialog*buttonbox.unfade.label:      Unfade Colormap
-*resources_dialog*buttonbox.lock.label:                Require Password
-*resources_dialog*done.label:                  OK
-*resources_dialog*cancel.label:                        Cancel
-
-*splash_dialog*splashLabel1.label:             XScreenSaver %s
-*splash_dialog*splashLabel2.label:             Copyright Â© 1991-1998 by
-*splash_dialog*splashLabel3.label:             Jamie Zawinski <jwz@jwz.org>
-*splash_dialog*splash_form*label.label:                
-*splash_dialog*Dialog.label:                   
-*splash_dialog*splash_form.borderWidth:                0
-*splash_dialog*roger.width:                    150
-*splash_dialog*roger.height:                   150
-*splash_dialog*roger.borderWidth:              1
-*splash_dialog*demo.label:                     Demo
-*splash_dialog*prefs.label:                    Prefs
-*splash_dialog*help.label:                     Help
-*splash_dialog.box.defaultDistance:            0
-*splash_dialog*splashLabel1.internalHeight:    10
-*splash_dialog*splashLabel1.internalWidth:     10
-*splash_dialog*splashLabel2.internalHeight:    0
-*splash_dialog*splashLabel3.internalHeight:    0
-
-
-
-! You probably won't need to change these.  They are only used if no server
-! extension is in use.
-!
-XScreenSaver.pointerPollTime:          5
-XScreenSaver.initialDelay:             0
-XScreenSaver.windowCreationTimeout:    30
-XScreenSaver.bourneShell:              /bin/sh
+*preferences_dialog*timeout.label:             Saver Timeout:
+*preferences_dialog*cycle.label:               Cycle Timeout:
+*preferences_dialog*fade.label:                        Fade Duration:
+*preferences_dialog*ticks.label:               Fade Ticks:
+*preferences_dialog*lockTime.label:            Lock Timeout:
+*preferences_dialog*passwdTime.label:          Password Timeout:
+XScreenSaver.preferences_dialog*Command.internalWidth:  10
+XScreenSaver.preferences_dialog*Command.internalHeight: 4
+
+*preferences_dialog*label1.label:              XScreenSaver Parameters
+*preferences_dialog*buttonbox.verbose.label:   Verbose
+*preferences_dialog*buttonbox.cmap.label:      Install Colormap
+*preferences_dialog*buttonbox.fade.label:      Fade Colormap
+*preferences_dialog*buttonbox.unfade.label:    Unfade Colormap
+*preferences_dialog*buttonbox.lock.label:      Require Password
+*preferences_dialog*done.label:                        Ok
+*preferences_dialog*cancel.label:              Cancel
+
+*warning_dialog*ok.label:                      Ok
+
+*warning_dialog*horizDistance:                 30
+*warning_dialog*vertDistance:                  0
+
+*warning_dialog*Label.internalWidth:           1
+*warning_dialog*Label.internalHeight:          0
+
+*warning_dialog*label0.horizDistance:          80
+*warning_dialog*label0.vertDistance:           20
+
+*warning_dialog*Command.horizDistance:         160
+*warning_dialog*Command.vertDistance:          20
+*warning_dialog*Command.internalWidth:         20
+*warning_dialog*Command.internalHeight:                5
index 680d861904cbf0cb4de2ca4375984260e452fd30..61de93c455747af9ead805712175ba7865007e6e 100644 (file)
 "*overlayTextBackground:       #000000",
 "*overlayStderr:               True",
 "*font:                        *-medium-r-*-140-*-m-*",
+"*demoCommand: xscreensaver-demo",
+"*prefsCommand: xscreensaver-demo -prefs",
 "*helpURL: http://www.jwz.org/xscreensaver/man.html",
-"*loadURL: netscape -remote 'openURL(%s)' || netscape '%s' &",
+"*loadURL: netscape -remote 'openURL(%s)' || netscape '%s'",
 "*installColormap:     True",
 "*programs:    qix -root -solid -delay 0 -segments 100                 \\n\
                attraction -root -mode balls                            \\n\
@@ -40,6 +42,7 @@
                jigsaw -root                                            \\n\
                blitspin -root -grab                                    \\n\
                slip -root                                              \\n\
+               distort -root                                           \\n\
                hypercube -root                                         \\n\
                halo -root                                              \\n\
                maze -root                                              \\n\
@@ -83,6 +86,7 @@
                vines -root                                             \\n\
                kaleidescope -root                                      \\n\
                xjack -root                                             \\n\
+  -            xlyap -root -randomize                                  \\n\
                cynosure -root                                          \\n\
                flow -root                                              \\n\
                epicycle -root                                          \\n\
@@ -92,6 +96,8 @@
                crystal -root                                           \\n\
                discrete -root                                          \\n\
                kumppa -root                                            \\n\
+               rd-bomb -root                                           \\n\
+               rd-bomb -root -speed 1 -size 0.1                        \\n\
                                                                          \
        mono:   rocks -root                                             \\n\
        color:  rocks -root -fg darksalmon                              \\n\
        color:  attraction -root -glow -points 10                       \\n\
        color:  bubbles -root                                           \\n\
                                                                          \
-        color:  rd-bomb -root                                          \\n\
-        color:  rd-bomb -root -speed 1 -size 0.1                       \\n\
-                                                                         \
   PseudoColor: qix -root -count 4 -solid -transparent                  \\n\
   PseudoColor: qix -root -count 5 -solid -transparent -linear            \
                        -segments 250 -size 100                         \\n\
                bubble3d -root                                          \\n\
                glplanet -root                                          \\n",
 " ",
+"XScreenSaver.pointerPollTime:         5",
+"XScreenSaver.initialDelay:            0",
+"XScreenSaver.windowCreationTimeout:   30",
+"XScreenSaver.bourneShell:             /bin/sh",
 "*Dialog.headingFont:          *-times-bold-r-*-*-*-180-*-*-*-iso8859-1",
 "*Dialog.bodyFont:             *-helvetica-bold-r-*-*-*-140-*-*-*-iso8859-1",
 "*Dialog.labelFont:            *-helvetica-bold-r-*-*-*-140-*-*-*-iso8859-1",
 "*fontList:                       *-helvetica-medium-r-*-*-*-120-*-*-*-iso8859-1",
 "*demoDialog*label1.fontList:     *-helvetica-medium-r-*-*-*-140-*-*-*-iso8859-1",
 "*XmTextField.fontList:             *-courier-medium-r-*-*-*-120-*-*-*-iso8859-1",
-"*splashDialog*fontList:                  *-helvetica-bold-r-*-*-*-120-*-*-*-iso8859-1",
-"*splashDialog*splashLabel1.fontList:   *-times-bold-r-*-*-*-180-*-*-*-iso8859-1",
-"*splashDialog*splashLabel2.fontList:   *-times-bold-r-*-*-*-140-*-*-*-iso8859-1",
-"*splashDialog*splashLabel3.fontList:   *-times-bold-r-*-*-*-140-*-*-*-iso8859-1",
+"*label0.fontList:                  *-helvetica-bold-r-*-*-*-140-*-*-*-iso8859-1",
 "XScreenSaver*XmList.fontList:      *-courier-medium-r-*-*-*-120-*-*-*-iso8859-1",
 "*XmDialogShell*foreground:            #000000",
 "*XmDialogShell*background:            #E5E5E5",
 "*XmDialogShell*XmTextField.background:        #FFFFFF",
 "*XmDialogShell*demoList.foreground:   #000000",
 "*XmDialogShell*demoList.background:   #FFFFFF",
-"XScreenSaver*XmDialogShell*rogerLabel.foreground:     #CD0000",
-"XScreenSaver*XmDialogShell*rogerLabel.background:     #FFFFFF",
 "*XmDialogShell.title:         XScreenSaver",
+"*versionWarning_popup.title:  XScreenSaver Warning",
+"*demoForm_popup.title:                XScreenSaver Demo",
+"*preferencesForm_popup.title: XScreenSaver Preferences",
 "*allowShellResize:            True",
 "*autoUnmanage:                        False",
 "*demoDialog.maxWidth:         600",
 "*next.labelString:            Run Next",
 "*prev.labelString:            Run Previous",
 "*edit.labelString:            Preferences",
-"*done.labelString:            Exit Demo Mode",
 "*restart.labelString:         Reinitialize",
-"*resourcesLabel.labelString:  XScreenSaver Parameters",
+"*done.labelString:            Quit",
+"*preferencesLabel.labelString:        XScreenSaver Parameters",
 "*timeoutLabel.labelString:    Saver Timeout",
 "*cycleLabel.labelString:      Cycle Timeout",
 "*fadeSecondsLabel.labelString:        Fade Duration",
 "*fadeTicksLabel.labelString:  Fade Ticks",
 "*lockLabel.labelString:               Lock Timeout",
 "*passwdLabel.labelString:     Password Timeout",
-"*resourcesForm*XmTextField.columns:   8",
+"*preferencesForm*XmTextField.columns: 8",
 "*verboseToggle.labelString:   Verbose",
 "*cmapToggle.labelString:      Install Colormap",
 "*fadeToggle.labelString:      Fade Colormap",
 "*unfadeToggle.labelString:    Unfade Colormap",
 "*lockToggle.labelString:      Require Password",
-"*resourcesDone.labelString:   OK",
-"*resourcesCancel.labelString: Cancel",
-"*splashDialog.title:          XScreenSaver",
-"*splashLabel1.labelString:    XScreenSaver %s",
-"*splashLabel2.labelString:    Copyright Â© 1991-1998 by",
-"*splashLabel3.labelString:    Jamie Zawinski <jwz@jwz.org>",
-"*splashDemo.labelString:      Demo",
-"*splashPrefs.labelString:     Prefs",
-"*splashDialog*Help.labelString:       Help",
-"*splashLabel1.alignment:      ALIGNMENT_CENTER",
-"*splashLabel2.alignment:      ALIGNMENT_CENTER",
-"*splashLabel3.alignment:      ALIGNMENT_CENTER",
-"*splashDialog.borderWidth:    1",
-"*splashForm.shadowThickness:  4",
+"*preferencesDone.labelString: OK",
+"*preferencesCancel.labelString:       Cancel",
 "XScreenSaver*dragInitiatorProtocolStyle: DRAG_NONE",
 "XScreenSaver*dragReceiverProtocolStyle:  DRAG_NONE",
+"*demo_dialog.title:           XScreenSaver Demo",
+"*preferences_dialog.title:    XScreenSaver Preferences",
+"*warning_dialog.title:                XScreenSaver Warning",
+"*demo_dialog.geometry:                =640x400",
 "*demo_dialog*font:            *-helvetica-bold-r-*-*-*-120-*-*-*-iso8859-1",
-"*resources_dialog*font:               *-helvetica-bold-r-*-*-*-120-*-*-*-iso8859-1",
-"*splash_dialog*font:          *-helvetica-bold-r-*-*-*-140-*-*-*-iso8859-1",
-"*splash_dialog*splashLabel1.font:   *-times-bold-r-*-*-*-180-*-*-*-iso8859-1",
-"*splash_dialog*splashLabel2.font:   *-times-bold-r-*-*-*-140-*-*-*-iso8859-1",
-"*splash_dialog*splashLabel3.font:   *-times-bold-r-*-*-*-140-*-*-*-iso8859-1",
+"*preferences_dialog*font:     *-helvetica-bold-r-*-*-*-120-*-*-*-iso8859-1",
 "*demo_dialog*label1.font:     *-helvetica-bold-r-*-*-*-140-*-*-*-iso8859-1",
-"*resources_dialog*label1.font:        *-helvetica-bold-r-*-*-*-140-*-*-*-iso8859-1",
-"XScreenSaver.demo_dialog*List.font: \
+"*preferences_dialog*label1.font:*-helvetica-bold-r-*-*-*-140-*-*-*-iso8859-1",
+"XScreenSaver*warning_dialog*label0.font:      \
+                               *-helvetica-bold-r-*-*-*-140-*-*-*-iso8859-1",
+"XScreenSaver*warning_dialog*Label.font:       \
+                               *-helvetica-bold-r-*-*-*-120-*-*-*-iso8859-1",
+"XScreenSaver*warning_dialog*Command.font: \
+                               *-helvetica-bold-r-*-*-*-140-*-*-*-iso8859-1",
+"XScreenSaver.demo_dialog*List.font:   \
                                *-courier-medium-r-*-*-*-120-*-*-*-iso8859-1",
-"XScreenSaver.demo_dialog*Text*font: \
+"XScreenSaver.demo_dialog*Text*font:   \
                                *-courier-medium-r-*-*-*-120-*-*-*-iso8859-1",
 "XScreenSaver.demo_dialog*foreground:                  #000000",
 "XScreenSaver.demo_dialog*background:                  #E5E5E5",
 "XScreenSaver.demo_dialog*Scrollbar.background:                #D9D9D9",
 "XScreenSaver.demo_dialog*Command.background:          #D9D9D9",
 "XScreenSaver.demo_dialog*Text*background:             #FFFFFF",
-"XScreenSaver.resources_dialog*foreground:             #000000",
-"XScreenSaver.resources_dialog*background:             #E5E5E5",
-"XScreenSaver.resources_dialog*Command.background:     #D9D9D9",
-"XScreenSaver.resources_dialog*Toggle.background:      #D9D9D9",
-"XScreenSaver.resources_dialog*Text*background:                #FFFFFF",
-"*resources_dialog*Dialog.value.translations: #override\\n\
+"XScreenSaver.preferences_dialog*foreground:           #000000",
+"XScreenSaver.preferences_dialog*background:           #E5E5E5",
+"XScreenSaver.preferences_dialog*Command.background:   #D9D9D9",
+"XScreenSaver.preferences_dialog*Toggle.background:    #D9D9D9",
+"XScreenSaver.preferences_dialog*Text*background:      #FFFFFF",
+"XScreenSaver.warning_dialog*foreground:                       #000000",
+"XScreenSaver.warning_dialog*background:                       #E5E5E5",
+"XScreenSaver.warning_dialog*Command.background:               #D9D9D9",
+"*preferences_dialog*Dialog.value.translations: #override\\n\
        <Key>Return: beginning-of-line()\\n",
-"XScreenSaver.splash_dialog*foreground:                        #000000",
-"XScreenSaver.splash_dialog*background:                        #E5E5E5",
-"XScreenSaver.splash_dialog*Command.background:                #D9D9D9",
-"XScreenSaver.splash_dialog*Text*background:           #FFFFFF",
-"XScreenSaver.splash_dialog*roger.foreground:          #CD0000",
-"XScreenSaver.splash_dialog*roger.background:          #FFFFFF",
 "*demo_dialog*viewport.height:                 200",
 "*Form.borderWidth:                            0",
 "*Box.borderWidth:                             0",
 "*Label.borderWidth:                           0",
-"*resources_dialog*Dialog.borderWidth:         0",
+"*preferences_dialog*Dialog.borderWidth:               0",
 "*demo_dialog*next.label:                      Run Next",
 "*demo_dialog*prev.label:                      Run Previous",
 "*demo_dialog*edit.label:                      Preferences",
-"*demo_dialog*done.label:                      Exit Demo Mode",
 "*demo_dialog*restart.label:                   Reinitialize",
+"*demo_dialog*done.label:                      Quit",
 "XScreenSaver.demo_dialog*Command.internalWidth:  10",
 "XScreenSaver.demo_dialog*Command.internalHeight: 4",
-"*resources_dialog*timeout.label:              Saver Timeout:",
-"*resources_dialog*cycle.label:                        Cycle Timeout:",
-"*resources_dialog*fade.label:                 Fade Duration:",
-"*resources_dialog*ticks.label:                        Fade Ticks:",
-"*resources_dialog*lockTime.label:             Lock Timeout:",
-"*resources_dialog*passwdTime.label:           Password Timeout:",
-"*resources_dialog*label1.label:                       XScreenSaver Parameters",
-"*resources_dialog*buttonbox.verbose.label:    Verbose",
-"*resources_dialog*buttonbox.cmap.label:               Install Colormap",
-"*resources_dialog*buttonbox.fade.label:               Fade Colormap",
-"*resources_dialog*buttonbox.unfade.label:     Unfade Colormap",
-"*resources_dialog*buttonbox.lock.label:               Require Password",
-"*resources_dialog*done.label:                 OK",
-"*resources_dialog*cancel.label:                       Cancel",
-"*splash_dialog*splashLabel1.label:            XScreenSaver %s",
-"*splash_dialog*splashLabel2.label:            Copyright Â© 1991-1998 by",
-"*splash_dialog*splashLabel3.label:            Jamie Zawinski <jwz@jwz.org>",
-"*splash_dialog*splash_form*label.label:               ",
-"*splash_dialog*Dialog.label:                  ",
-"*splash_dialog*splash_form.borderWidth:               0",
-"*splash_dialog*roger.width:                   150",
-"*splash_dialog*roger.height:                  150",
-"*splash_dialog*roger.borderWidth:             1",
-"*splash_dialog*demo.label:                    Demo",
-"*splash_dialog*prefs.label:                   Prefs",
-"*splash_dialog*help.label:                    Help",
-"*splash_dialog.box.defaultDistance:           0",
-"*splash_dialog*splashLabel1.internalHeight:   10",
-"*splash_dialog*splashLabel1.internalWidth:    10",
-"*splash_dialog*splashLabel2.internalHeight:   0",
-"*splash_dialog*splashLabel3.internalHeight:   0",
-"XScreenSaver.pointerPollTime:         5",
-"XScreenSaver.initialDelay:            0",
-"XScreenSaver.windowCreationTimeout:   30",
-"XScreenSaver.bourneShell:             /bin/sh",
+"*preferences_dialog*timeout.label:            Saver Timeout:",
+"*preferences_dialog*cycle.label:              Cycle Timeout:",
+"*preferences_dialog*fade.label:                       Fade Duration:",
+"*preferences_dialog*ticks.label:              Fade Ticks:",
+"*preferences_dialog*lockTime.label:           Lock Timeout:",
+"*preferences_dialog*passwdTime.label:         Password Timeout:",
+"XScreenSaver.preferences_dialog*Command.internalWidth:  10",
+"XScreenSaver.preferences_dialog*Command.internalHeight: 4",
+"*preferences_dialog*label1.label:             XScreenSaver Parameters",
+"*preferences_dialog*buttonbox.verbose.label:  Verbose",
+"*preferences_dialog*buttonbox.cmap.label:     Install Colormap",
+"*preferences_dialog*buttonbox.fade.label:     Fade Colormap",
+"*preferences_dialog*buttonbox.unfade.label:   Unfade Colormap",
+"*preferences_dialog*buttonbox.lock.label:     Require Password",
+"*preferences_dialog*done.label:                       Ok",
+"*preferences_dialog*cancel.label:             Cancel",
+"*warning_dialog*ok.label:                     Ok",
+"*warning_dialog*horizDistance:                        30",
+"*warning_dialog*vertDistance:                 0",
+"*warning_dialog*Label.internalWidth:          1",
+"*warning_dialog*Label.internalHeight:         0",
+"*warning_dialog*label0.horizDistance:         80",
+"*warning_dialog*label0.vertDistance:          20",
+"*warning_dialog*Command.horizDistance:                160",
+"*warning_dialog*Command.vertDistance:         20",
+"*warning_dialog*Command.internalWidth:                20",
+"*warning_dialog*Command.internalHeight:               5",
index c7a12ba3eb4b4c5e458440768e9672a8ff6f287a..e92e9617a1da6c111758a8e2dd2a1fbdeeab86d3 100644 (file)
 # include "config.h"
 #endif
 
+#ifdef HAVE_ATHENA_KLUDGE      /* don't ask */
+# undef HAVE_MOTIF
+# define HAVE_ATHENA 1
+#endif
+
+#include <stdlib.h>
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#ifndef VMS
+# include <pwd.h>              /* for getpwuid() */
+#else /* VMS */
+# include "vms-pwd.h"
+#endif /* VMS */
+
+#ifdef HAVE_UNAME
+# include <sys/utsname.h>      /* for uname() */
+#endif /* HAVE_UNAME */
+
+#include <stdio.h>
+
 #include <X11/Intrinsic.h>
 #include <X11/StringDefs.h>
 
@@ -27,6 +50,9 @@
 # include <Xm/Text.h>
 # include <Xm/List.h>
 # include <Xm/ToggleB.h>
+# include <Xm/MessageB.h>
+# include <Xm/LabelG.h>
+# include <Xm/RowColumn.h>
 
 #else  /* HAVE_ATHENA */
   /* Athena demo code contributed by Jon A. Christopher <jac8782@tamu.edu> */
 # include <X11/Xaw/Text.h>
 #endif /* HAVE_ATHENA */
 
-#include "xscreensaver.h"
+#include "version.h"
+#include "prefs.h"
 #include "resources.h"         /* for parse_time() */
+#include "visual.h"            /* for has_writable_cells() */
+#include "remote.h"            /* for xscreensaver_command() */
+
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
 
-#ifdef _VROOT_H_
-ERROR!  You must not include vroot.h in this file.
-#endif
 
-static void demo_mode_hack (saver_info *si, char *);
-static void demo_mode_done (saver_info *si);
+char *progname = 0;
+char *progclass = "XScreenSaver";
+XrmDatabase db;
+
+typedef struct {
+  saver_preferences *a, *b;
+} prefs_pair;
+
+
+char *blurb (void) { return progname; }
+
+static void run_hack (Display *dpy, int n);
+
+#ifdef HAVE_ATHENA
+static saver_preferences *global_prefs_kludge = 0;    /* I hate C so much... */
+#endif /* HAVE_ATHENA */
+
+static char *short_version = 0;
+
+Atom XA_VROOT;
+Atom XA_SCREENSAVER, XA_SCREENSAVER_RESPONSE, XA_SCREENSAVER_VERSION;
+Atom XA_SCREENSAVER_TIME, XA_SCREENSAVER_ID, XA_SELECT, XA_DEMO, XA_RESTART;
+
+extern void create_demo_dialog (Widget, Visual *, Colormap);
+extern void create_preferences_dialog (Widget, Visual *, Colormap);
 
 extern Widget demo_dialog;
 extern Widget label1;
@@ -63,12 +113,12 @@ extern Widget demo_form;
 extern Widget demo_list;
 extern Widget next, prev, done, restart, edit;
 
-extern Widget resources_dialog;
-extern Widget resources_form;
-extern Widget res_done, res_cancel;
-extern Widget timeout_text, cycle_text, fade_text, ticks_text;
-extern Widget lock_time_text, passwd_time_text;
-extern Widget verbose_toggle, cmap_toggle, fade_toggle, unfade_toggle,
+extern Widget preferences_dialog;
+extern Widget preferences_form;
+extern Widget prefs_done, prefs_cancel;
+extern Widget timeout_text, cycle_text, fade_text, fade_ticks_text;
+extern Widget lock_timeout_text, passwd_timeout_text;
+extern Widget verbose_toggle, install_cmap_toggle, fade_toggle, unfade_toggle,
   lock_toggle;
 
 
@@ -152,11 +202,11 @@ set_label_string (Widget label_widget, char *string)
 }
 
 
-void
+static void
 format_into_label (Widget label, const char *arg)
 {
   char *text = get_label_string (label);
-  char *buf = (char *) malloc ((text ? strlen(text) : 100) + strlen(arg) + 10);
+  char *buf = (char *) malloc ((text ? strlen(text) : 0) + strlen(arg) + 100);
 
   if (!text || !strcmp (text, XtName (label)))
       strcpy (buf, "ERROR: RESOURCES ARE NOT INSTALLED CORRECTLY");
@@ -169,119 +219,6 @@ format_into_label (Widget label, const char *arg)
 }
 
 
-void
-steal_focus_and_colormap (Widget dialog)
-{
-  Display *dpy = XtDisplay (dialog);
-  Window window = XtWindow (dialog);
-  Colormap cmap = 0;
-  XSetInputFocus (dpy, window, RevertToParent, CurrentTime);
-
-  XtVaGetValues (dialog, XtNcolormap, &cmap, 0);
-  if (cmap)
-    XInstallColormap (dpy, cmap);
-}
-
-static void
-raise_screenhack_dialog (void)
-{
-  XMapRaised (XtDisplay (demo_dialog), XtWindow (demo_dialog));
-  if (resources_dialog)
-    XMapRaised (XtDisplay (resources_dialog), XtWindow (resources_dialog));
-  steal_focus_and_colormap (resources_dialog ? resources_dialog : demo_dialog);
-}
-
-static void
-destroy_screenhack_dialogs (saver_info *si)
-{
-  saver_screen_info *ssi = si->default_screen;
-
-  if (demo_dialog) XtDestroyWidget (demo_dialog);
-  if (resources_dialog) XtDestroyWidget (resources_dialog);
-  demo_dialog = resources_dialog = 0;
-
-  if (ssi->demo_cmap &&
-      ssi->demo_cmap != ssi->cmap &&
-      ssi->demo_cmap != DefaultColormapOfScreen (ssi->screen))
-    {
-      XFreeColormap (si->dpy, ssi->demo_cmap);
-      ssi->demo_cmap = 0;
-    }
-
-  /* Since we installed our colormap to display the dialogs properly, put
-     the old one back, so that the screensaver_window is now displayed
-     properly. */
-  if (ssi->cmap)
-    XInstallColormap (si->dpy, ssi->cmap);
-}
-
-
-static void
-text_cb (Widget text_widget, XtPointer client_data, XtPointer call_data)
-{
-  saver_info *si = (saver_info *) client_data;
-  saver_preferences *p = &si->prefs;
-  char *line;
-  line = get_text_string (text_widget);
-
-  if (p->verbose_p)
-    fprintf (stderr, "%s: processing text \"%s\".\n", blurb(), line);
-
-  demo_mode_hack (si, line);
-}
-
-
-#ifdef HAVE_ATHENA
-/* Bend over backwards to make hitting Return in the text field do the
-   right thing. 
-   */
-extern saver_info *global_si_kludge;
-static void text_enter (Widget w, XEvent *event, String *av, Cardinal *ac)
-{
-  text_cb (w, global_si_kludge, 0);
-}
-
-static XtActionsRec actions[] = {{"done",      text_enter}
-                               };
-static char translations[] = ("<Key>Return:    done()\n"
-                             "<Key>Linefeed:   done()\n"
-                             "Ctrl<Key>M:      done()\n"
-                             "Ctrl<Key>J:      done()\n");
-#endif /* HAVE_ATHENA */
-
-
-static void
-select_cb (Widget button, XtPointer client_data, XtPointer call_data)
-{
-  saver_info *si = (saver_info *) client_data;
-
-#ifdef HAVE_ATHENA
-  XawListReturnStruct *item = (XawListReturnStruct*)call_data;
-  XtVaSetValues(text_line, XtNstring, item->string, 0);
-
-  demo_mode_hack (si, item->string);
-  if (item->list_index >= 0)
-    si->default_screen->current_hack = item->list_index;
-
-#else  /* HAVE_MOTIF */
-  XmListCallbackStruct *lcb = (XmListCallbackStruct *) call_data;
-  char *string = 0;
-  if (lcb->item)
-    XmStringGetLtoR (lcb->item, XmSTRING_DEFAULT_CHARSET, &string);
-  set_text_string (text_line, (string ? string : ""));
-  if (lcb->reason == XmCR_DEFAULT_ACTION && string)
-    {
-      demo_mode_hack (si, string);
-      if (lcb->item_position > 0)
-       si->default_screen->current_hack = lcb->item_position - 1;
-    }
-  if (string)
-    XtFree (string);
-#endif /* HAVE_MOTIF */
-  steal_focus_and_colormap (demo_dialog);
-}
-
-
 /* Why this behavior isn't automatic in *either* toolkit, I'll never know.
  */
 static void
@@ -365,272 +302,326 @@ ensure_selected_item_visible (Widget list)
 }
 
 
+/* Callback for the text area:
+   - note the text the user has entered;
+   - change the corresponding element in `screenhacks';
+   - write the .xscreensaver file;
+   - tell the xscreensaver daemon to run that hack.
+ */
 static void
-next_cb (Widget button, XtPointer client_data, XtPointer call_data)
+text_cb (Widget text_widget, XtPointer client_data, XtPointer call_data)
 {
-  saver_info *si = (saver_info *) client_data;
-  saver_preferences *p = &si->prefs;
+  Display *dpy = XtDisplay (text_widget);
+  saver_preferences *p = (saver_preferences *) client_data;
+  char *new_text = get_text_string (text_widget);
 
-  if (p->verbose_p)
-    fprintf (stderr, "%s: Run Next\n", blurb());
+  int hack_number = -1;                /* 0-based */
 
-  {
 #ifdef HAVE_ATHENA
-  int cnt;
   XawListReturnStruct *current = XawListShowCurrent(demo_list);
-  if (current->list_index == XAW_LIST_NONE)
-    XawListHighlight(demo_list, 0);
+  hack_number = current->list_index;
+#else  /* HAVE_MOTIF */
+  int *pos_list = 0;
+  int pos_count = 0;
+  if (XmListGetSelectedPos (demo_list, &pos_list, &pos_count))
+    hack_number = pos_list[0] - 1;
+  if (pos_list)
+    XtFree ((char *) pos_list);
+#endif /* HAVE_MOTIF */
+
+  ensure_selected_item_visible (demo_list);
+
+  if (hack_number < 0 || hack_number >= p->screenhacks_count)
+    {
+      set_text_string (text_widget, "");
+      XBell (dpy, 0);
+    }
   else
     {
-      XtVaGetValues(demo_list,
-                   XtNnumberStrings, &cnt,
-                   NULL);
-      if (current->list_index + 1 < cnt)
-       {
-         current->list_index++;
-         XawListHighlight(demo_list, current->list_index);
-       }
+fprintf(stderr, "%d:\nold: %s\nnew: %s\n",
+       hack_number, p->screenhacks [hack_number], new_text);
+
+      if (p->screenhacks [hack_number])
+       free (p->screenhacks [hack_number]);
+      p->screenhacks [hack_number] = strdup (new_text);
+
+#ifdef HAVE_MOTIF
+
+      XmListDeselectAllItems (demo_list);
+      {
+       XmString xmstr = XmStringCreate (new_text, XmSTRING_DEFAULT_CHARSET);
+       XmListReplaceItemsPos (demo_list, &xmstr, 1, hack_number+1);
+       XmStringFree (xmstr);
+      }
+      XmListSelectPos (demo_list, hack_number+1, True);
+
+#else  /* HAVE_ATHENA */
+
+      {
+       Widget vp = XtParent(demo_list);
+       Widget sb = (vp ? XtNameToWidget(vp, "*vertical") : 0);
+       Dimension list_h = 0;
+       Position vp_x = 0, vp_y = 0;
+       float sb_top = 0;
+
+       XawListUnhighlight (demo_list);
+
+       XtVaGetValues (vp, XtNx, &vp_x, 0);
+       XtVaGetValues (sb, XtNtopOfThumb, &sb_top, 0);
+       XtVaGetValues (demo_list, XtNheight, &list_h, 0);
+       vp_y = (sb_top * list_h);
+       XtVaSetValues (demo_list,
+                      XtNlist, p->screenhacks,
+                      XtNnumberStrings, p->screenhacks_count,
+                      0);
+       XawViewportSetCoordinates (vp, vp_x, vp_y);
+       XawListHighlight (demo_list, hack_number);
+      }
+
+#endif /* HAVE_ATHENA */
+
+      write_init_file (p, short_version);
+      XSync (dpy, False);
+      usleep (500000);         /* give the disk time to settle down */
+
+      run_hack (dpy, hack_number+1);
     }
+}
+
+
+#ifdef HAVE_ATHENA
+/* Bend over backwards to make hitting Return in the text field do the
+   right thing. 
+   */
+static void text_enter (Widget w, XEvent *event, String *av, Cardinal *ac)
+{
+  text_cb (w, global_prefs_kludge, 0);   /* I hate C so much... */
+}
+
+static XtActionsRec actions[] = {{"done",      text_enter}
+                               };
+static char translations[] = ("<Key>Return:    done()\n"
+                             "<Key>Linefeed:   done()\n"
+                             "Ctrl<Key>M:      done()\n"
+                             "Ctrl<Key>J:      done()\n");
+#endif /* HAVE_ATHENA */
+
+
+/* Callback for the Run Next button.
+ */
+static void
+next_cb (Widget button, XtPointer client_data, XtPointer call_data)
+{
+#ifdef HAVE_ATHENA
+  XawListReturnStruct *current = XawListShowCurrent(demo_list);
+  int cnt;
+  XtVaGetValues (demo_list, XtNnumberStrings, &cnt, 0);
+  if (current->list_index == XAW_LIST_NONE ||
+      current->list_index + 1 >= cnt)
+    current->list_index = 0;
+  else
+    current->list_index++;
+  XawListHighlight(demo_list, current->list_index);
 
   ensure_selected_item_visible (demo_list);
   current = XawListShowCurrent(demo_list);
   XtVaSetValues(text_line, XtNstring, current->string, 0);
-  demo_mode_hack (si, current->string);
+
+  run_hack (XtDisplay (button), current->list_index + 1);
 
 #else  /* HAVE_MOTIF */
 
-  int *pos_list;
-  int pos_count;
+  saver_preferences *p = (saver_preferences *) client_data;
+  int *pos_list = 0;
+  int pos_count = 0;
+  int pos;
   if (! XmListGetSelectedPos (demo_list, &pos_list, &pos_count))
     {
-      XmListDeselectAllItems(demo_list);       /* LessTif lossage */
-      XmListSelectPos (demo_list, 1, True);
+      pos = 1;
+      XmListDeselectAllItems (demo_list);      /* LessTif lossage */
+      XmListSelectPos (demo_list, pos, True);
     }
   else
     {
-      int pos = pos_list[0] + 1;
-      if (pos > si->prefs.screenhacks_count)
+      pos = pos_list[0] + 1;
+      if (pos > p->screenhacks_count)
        pos = 1;
-      XmListDeselectAllItems(demo_list);       /* LessTif lossage */
+      XmListDeselectAllItems (demo_list);      /* LessTif lossage */
       XmListSelectPos (demo_list, pos, True);
     }
-  XtFree ((char *) pos_list);
+     
   ensure_selected_item_visible (demo_list);
-  demo_mode_hack (si, get_text_string (text_line));
+  run_hack (XtDisplay (button), pos);
+  if (pos_list)
+    XtFree ((char *) pos_list);
 
 #endif /* HAVE_MOTIF */
-  }
 }
 
 
+/* Callback for the Run Previous button.
+ */
 static void
 prev_cb (Widget button, XtPointer client_data, XtPointer call_data)
 {
-  saver_info *si = (saver_info *) client_data;
-  saver_preferences *p = &si->prefs;
-
-  if (p->verbose_p)
-    fprintf (stderr, "%s: Run Previous\n", blurb());
-
-  {
 #ifdef HAVE_ATHENA
-  XawListReturnStruct *current=XawListShowCurrent(demo_list);
-  if (current->list_index == XAW_LIST_NONE)
-    XawListHighlight(demo_list, 0);
+  XawListReturnStruct *current = XawListShowCurrent(demo_list);
+  int cnt;
+  XtVaGetValues (demo_list, XtNnumberStrings, &cnt, 0);
+  if (current->list_index == XAW_LIST_NONE ||
+      current->list_index <= 0)
+    current->list_index = cnt-1;
   else
-    {
-      if (current->list_index >= 1)
-       {
-         current->list_index--;
-         XawListHighlight(demo_list, current->list_index);
-       }
-    }
+    current->list_index--;
+  XawListHighlight(demo_list, current->list_index);
 
   ensure_selected_item_visible (demo_list);
   current = XawListShowCurrent(demo_list);
   XtVaSetValues(text_line, XtNstring, current->string, 0);
-  demo_mode_hack (si, current->string);
+
+  run_hack (XtDisplay (button), current->list_index + 1);
 
 #else  /* HAVE_MOTIF */
 
-  int *pos_list;
-  int pos_count;
+  saver_preferences *p = (saver_preferences *) client_data;
+  int *pos_list = 0;
+  int pos_count = 0;
+  int pos;
   if (! XmListGetSelectedPos (demo_list, &pos_list, &pos_count))
     {
-      XmListDeselectAllItems(demo_list);       /* LessTif lossage */
-      XmListSelectPos (demo_list, 0, True);
+      pos = p->screenhacks_count;
+      XmListDeselectAllItems (demo_list);      /* LessTif lossage */
+      XmListSelectPos (demo_list, pos, True);
     }
   else
     {
-      XmListDeselectAllItems(demo_list);       /* LessTif lossage */
-      XmListSelectPos (demo_list, pos_list [0] - 1, True);
-      XtFree ((char *) pos_list);
+      pos = pos_list[0] - 1;
+      if (pos == 0)
+       pos = p->screenhacks_count;
+      XmListDeselectAllItems (demo_list);      /* LessTif lossage */
+      XmListSelectPos (demo_list, pos, True);
     }
+     
   ensure_selected_item_visible (demo_list);
-  demo_mode_hack (si, get_text_string (text_line));
+  run_hack (XtDisplay (button), pos);
+  if (pos_list)
+    XtFree ((char *) pos_list);
 
 #endif /* HAVE_MOTIF */
-  }
 }
 
 
-static void pop_resources_dialog (saver_info *si);
-static void make_resources_dialog (saver_info *si, Widget parent);
+/* Callback run when a list element is double-clicked.
+ */
+static void
+select_cb (Widget button, XtPointer client_data, XtPointer call_data)
+{
+/*  saver_preferences *p = (saver_preferences *) client_data; */
+
+#ifdef HAVE_ATHENA
+  XawListReturnStruct *item = (XawListReturnStruct*)call_data;
+  XtVaSetValues(text_line, XtNstring, item->string, 0);
+  run_hack (XtDisplay (button), item->list_index + 1);
+
+#else  /* HAVE_MOTIF */
+  XmListCallbackStruct *lcb = (XmListCallbackStruct *) call_data;
+  char *string = 0;
+  if (lcb->item)
+    XmStringGetLtoR (lcb->item, XmSTRING_DEFAULT_CHARSET, &string);
+  set_text_string (text_line, (string ? string : ""));
+
+  if (lcb->reason == XmCR_DEFAULT_ACTION && string)
+    run_hack (XtDisplay (button), lcb->item_position);
+
+  if (string)
+    XtFree (string);
+#endif /* HAVE_MOTIF */
+}
+
+
+
+static void pop_preferences_dialog (prefs_pair *pair);
+static void make_preferences_dialog (prefs_pair *pair, Widget parent);
 
+/* Callback for the Preferences button.
+ */
 static void
-edit_cb (Widget button, XtPointer client_data, XtPointer call_data)
+preferences_cb (Widget button, XtPointer client_data, XtPointer call_data)
 {
-  saver_info *si = (saver_info *) client_data;
-  saver_screen_info *ssi = si->default_screen;
-  saver_preferences *p = &si->prefs;
-  Widget parent = ssi->toplevel_shell;
+  prefs_pair *pair = (prefs_pair *) client_data;
+  Widget parent = button;
 
-  if (p->verbose_p)
-    fprintf (stderr, "%s: Preferences\n", blurb());
+  do {
+    parent = XtParent(parent);
+  } while (XtParent(parent));
 
-  if (! resources_dialog)
-    make_resources_dialog (si, parent);
-  pop_resources_dialog (si);
+  if (! preferences_dialog)
+    make_preferences_dialog (pair, parent);
+  pop_preferences_dialog (pair);
 }
 
+/* Callback for the Quit button.
+ */
 static void
-done_cb (Widget button, XtPointer client_data, XtPointer call_data)
+quit_cb (Widget button, XtPointer client_data, XtPointer call_data)
 {
-  saver_info *si = (saver_info *) client_data;
-  demo_mode_done (si);
+  /* Save here?  Right now we don't need to, because we save every time
+     the text field is edited, or the Preferences OK button is pressed.
+  */
+  exit (0);
 }
 
 
+/* Callback for the (now unused) Restart button.
+ */
 static void
 restart_cb (Widget button, XtPointer client_data, XtPointer call_data)
 {
-  saver_info *si = (saver_info *) client_data;
-  saver_preferences *p = &si->prefs;
-  if (p->verbose_p)
-    fprintf (stderr, "%s: Restart\n", blurb());
-  demo_mode_restart_process (si);
+  xscreensaver_command (XtDisplay (button), XA_RESTART, 0, False);
 }
 
 
-void
-pop_up_dialog_box (Widget dialog, Widget form, int where)
+static void
+pop_up_dialog_box (Widget dialog, Widget form)
 {
-  /* I'm sure this is the wrong way to pop up a dialog box, but I can't
-     figure out how else to do it.
-
-     It's important that the screensaver dialogs not get decorated or
-     otherwise reparented by the window manager, because they need to be
-     children of the *real* root window, not the WM's virtual root, in
-     order for us to guarentee that they are visible above the screensaver
-     window itself.
-   */
-  Arg av [100];
-  int ac = 0;
-  Dimension sw, sh, x, y, w, h;
-
 #ifdef HAVE_ATHENA
   XtRealizeWidget (dialog);
-#else  /* HAVE_MOTIF */
-  /* Motif likes us to realize the *child* of the shell... */
-  XtRealizeWidget (form);
-#endif /* HAVE_MOTIF */
-
-  sw = WidthOfScreen (XtScreen (dialog));
-  sh = HeightOfScreen (XtScreen (dialog));
-  ac = 0;
-  XtSetArg (av [ac], XtNwidth, &w); ac++;
-  XtSetArg (av [ac], XtNheight, &h); ac++;
-  XtGetValues (form, av, ac);
-
-  /* for debugging -- don't ask */
-  if (where >= 69)
-    {
-      where -= 69;
-      sw = (sw * 7) / 12;
-    }
-
-  switch (where)
-    {
-    case 0:    /* center it in the top-right quadrant */
-      x = (sw/2 + w) / 2 + (sw/2) - w;
-      y = (sh/2 + h) / 2 - h;
-      break;
-    case 1:    /* center it in the bottom-right quadrant */
-      x = (sw/2 + w) / 2 + (sw/2) - w;
-      y = (sh/2 + h) / 2 + (sh/2) - h;
-      break;
-    case 2:    /* center it on the screen */
-      x = (sw + w) / 2 - w;
-      y = (sh + h) / 2 - h;
-      break;
-    case 3:    /* center it in the top 2/3rds of the screen */
-      x = (sw + w) / 2 - w;
-      y = (sh*2/3 + h) / 2 - h;
-      break;
-    default:
-      abort ();
-    }
-  if (x + w > sw) x = sw - w;
-  if (y + h > sh) y = sh - h;
-  ac = 0;
-  XtSetArg (av [ac], XtNx, x); ac++;
-  XtSetArg (av [ac], XtNy, y); ac++;
-  XtSetArg (av [ac], XtNoverrideRedirect, True); ac++;
-
-#ifdef HAVE_MOTIF
-  XtSetArg (av [ac], XmNdefaultPosition, False); ac++;
-#endif /* HAVE_MOTIF */
-
-  XtSetValues (dialog, av, ac);
-  XtSetValues (form, av, ac);
-
-#ifdef HAVE_ATHENA
   XtPopup (dialog, XtGrabNone);
 #else  /* HAVE_MOTIF */
+  XtRealizeWidget (form);
   XtManageChild (form);
 #endif /* HAVE_MOTIF */
-
-  steal_focus_and_colormap (dialog);
+  XMapRaised (XtDisplay (dialog), XtWindow (dialog));
 }
 
 
-void
-make_screenhack_dialog (saver_info *si)
+static void
+make_demo_dialog (Widget toplevel_shell, prefs_pair *pair)
 {
-  saver_screen_info *ssi = si->default_screen;
-  Widget parent = ssi->toplevel_shell;
-  char **hacks = si->prefs.screenhacks;
+  saver_preferences *p =  pair->a;
+  /* saver_preferences *p2 = pair->b; */
 
-  if (ssi->demo_cmap &&
-      ssi->demo_cmap != ssi->cmap &&
-      ssi->demo_cmap != DefaultColormapOfScreen (ssi->screen))
-    {
-      XFreeColormap (si->dpy, ssi->demo_cmap);
-      ssi->demo_cmap = 0;
-    }
+  Widget parent = toplevel_shell;
+  char **hacks = p->screenhacks;
 
-  if (ssi->default_visual == DefaultVisualOfScreen (ssi->screen))
-    ssi->demo_cmap = DefaultColormapOfScreen (ssi->screen);
-  else
-    ssi->demo_cmap = XCreateColormap (si->dpy,
-                                     RootWindowOfScreen (ssi->screen),
-                                     ssi->default_visual, AllocNone);
+  create_demo_dialog (parent,
+                     DefaultVisualOfScreen (XtScreen (parent)),
+                     DefaultColormapOfScreen (XtScreen (parent)));
+  format_into_label (label1, short_version);
 
-  create_demo_dialog (parent, ssi->default_visual, ssi->demo_cmap);
-  format_into_label (label1, si->version);
-
-  add_button_callback (next,    next_cb,    (XtPointer) si);
-  add_button_callback (prev,    prev_cb,    (XtPointer) si);
-  add_button_callback (done,    done_cb,    (XtPointer) si);
-  add_button_callback (restart, restart_cb, (XtPointer) si);
-  add_button_callback (edit,    edit_cb,    (XtPointer) si);
+  add_button_callback (next,    next_cb,        (XtPointer) p);
+  add_button_callback (prev,    prev_cb,        (XtPointer) p);
+  add_button_callback (done,    quit_cb,        (XtPointer) p);
+  if (restart)
+    add_button_callback(restart,restart_cb,     (XtPointer) p);
+  add_button_callback (edit,    preferences_cb, (XtPointer) pair);
 
 #ifdef HAVE_MOTIF
   XtAddCallback (demo_list, XmNbrowseSelectionCallback,
-                select_cb, (XtPointer) si);
+                select_cb, (XtPointer) p);
   XtAddCallback (demo_list, XmNdefaultActionCallback,
-                select_cb, (XtPointer) si);
-  XtAddCallback (text_line, XmNactivateCallback, text_cb, (XtPointer) si);
+                select_cb, (XtPointer) p);
+  XtAddCallback (text_line, XmNactivateCallback, text_cb, (XtPointer) p);
 
   if (hacks)
     for (; *hacks; hacks++)
@@ -640,32 +631,6 @@ make_screenhack_dialog (saver_info *si)
        XmStringFree (xmstr);
       }
 
-  /* Cause the most-recently-run hack to be selected in the list.
-     Do some voodoo to make it be roughly centered in the list (really,
-     just make it not be within +/- 5 of the top/bottom if possible.)
-   */
-  if (ssi->current_hack > 0)
-    {
-      int i = ssi->current_hack+1;
-      int top = i + 5;
-      int bot = i - 5;
-      if (bot < 1) bot = 1;
-      if (top > si->prefs.screenhacks_count)
-       top = si->prefs.screenhacks_count;
-
-      XmListDeselectAllItems(demo_list);       /* LessTif lossage */
-      XmListSelectPos (demo_list, bot, False);
-      ensure_selected_item_visible (demo_list);
-
-      XmListDeselectAllItems(demo_list);       /* LessTif lossage */
-      XmListSelectPos (demo_list, top, False);
-      ensure_selected_item_visible (demo_list);
-
-      XmListDeselectAllItems(demo_list);       /* LessTif lossage */
-      XmListSelectPos (demo_list, i, False);
-      ensure_selected_item_visible (demo_list);
-    }
-
 #else  /* HAVE_ATHENA */
 
   /* Hook up the text line. */
@@ -682,11 +647,9 @@ make_screenhack_dialog (saver_info *si)
 
   XtVaSetValues (demo_list,
                 XtNlist, hacks,
-                XtNnumberStrings, si->prefs.screenhacks_count,
+                XtNnumberStrings, p->screenhacks_count,
                 0);
-  XtAddCallback (demo_list, XtNcallback, select_cb, si);
-  if (ssi->current_hack > 0)
-  XawListHighlight(demo_list, ssi->current_hack);
+  XtAddCallback (demo_list, XtNcallback, select_cb, p);
 
   /* Now that we've populated the list, make sure that the list is as
      wide as the dialog itself.
@@ -707,7 +670,6 @@ make_screenhack_dialog (saver_info *si)
     /* Why isn't the viewport getting centered? */
     XtVaGetValues(viewport,
                  XtNx, &x, XtNy, &y, XtNheight, &h, XtNborderWidth, &bw, 0);
-/*    printf("%d %d %d %d\n", x, y, w, h); */
     XtConfigureWidget(viewport, x, y, w2-x-x, h, bw);
 
     /* And the text line, too. */
@@ -732,11 +694,7 @@ make_screenhack_dialog (saver_info *si)
 
 #endif /* HAVE_ATHENA */
 
-  monitor_power_on (si);
-  pop_up_dialog_box(demo_dialog, demo_form,
-                   /* for debugging -- don't ask */
-                   (si->prefs.debug_p ? 69 : 0) +
-                   0);
+  pop_up_dialog_box(demo_dialog, demo_form);
 
 #ifdef HAVE_ATHENA
   /* For Athena, have to do this after the dialog is managed. */
@@ -745,21 +703,20 @@ make_screenhack_dialog (saver_info *si)
 }
 
 \f
-/* the Screensaver Parameters dialog */
-
-static struct resources {
-  int timeout, cycle, secs, ticks, lock_time, passwd_time;
-  int verb, cmap, fade, unfade, lock_p;
-} res;
-
+/* the Preferences dialog
+ */
 
+/* Helper for the text fields that contain time specifications:
+   this parses the text, and does error checking.
+ */
 static void 
-hack_time_cb (Display *dpy, char *line, int *store, Bool sec_p)
+hack_time_text (Display *dpy, char *line, Time *store, Bool sec_p)
 {
   if (*line)
     {
       int value;
       value = parse_time (line, sec_p, True);
+      value *= 1000;   /* Time measures in microseconds */
       if (value < 0)
        /*XBell (dpy, 0)*/;
       else
@@ -767,22 +724,34 @@ hack_time_cb (Display *dpy, char *line, int *store, Bool sec_p)
     }
 }
 
+
+/* Callback for text fields that hold a time that default to seconds,
+   when not fully spelled out.  client_data is an Time* where the value goes.
+ */
 static void
-res_sec_cb (Widget button, XtPointer client_data, XtPointer call_data)
+prefs_sec_cb (Widget button, XtPointer client_data, XtPointer call_data)
 {
-  hack_time_cb (XtDisplay (button), get_text_string (button),
-               (int *) client_data, True);
+  hack_time_text (XtDisplay (button), get_text_string (button),
+               (Time *) client_data, True);
 }
 
+
+/* Callback for text fields that hold a time that default to minutes,
+   when not fully spelled out.  client_data is an Time* where the value goes.
+ */
 static void
-res_min_cb (Widget button, XtPointer client_data, XtPointer call_data)
+prefs_min_cb (Widget button, XtPointer client_data, XtPointer call_data)
 {
-  hack_time_cb (XtDisplay (button), get_text_string (button),
-               (int *) client_data, False);
+  hack_time_text (XtDisplay (button), get_text_string (button),
+               (Time *) client_data, False);
 }
 
+
+/* Callback for text fields that hold an integer value.
+   client_data is an int* where the value goes.
+ */
 static void
-res_int_cb (Widget button, XtPointer client_data, XtPointer call_data)
+prefs_int_cb (Widget button, XtPointer client_data, XtPointer call_data)
 {
   char *line = get_text_string (button);
   int *store = (int *) client_data;
@@ -796,136 +765,88 @@ res_int_cb (Widget button, XtPointer client_data, XtPointer call_data)
     *store = value;
 }
 
+/* Callback for toggle buttons.  client_data is an Bool* where the value goes.
+ */
 static void
-res_bool_cb (Widget button, XtPointer client_data, XtPointer call_data)
+prefs_bool_cb (Widget button, XtPointer client_data, XtPointer call_data)
 {
-  int *store = (int *) client_data;
+  Bool *store = (Bool *) client_data;
 #ifdef HAVE_MOTIF
   *store = ((XmToggleButtonCallbackStruct *) call_data)->set;
 #else /* HAVE_ATHENA */
   Boolean state = FALSE;
-  XtVaGetValues (button, XtNstate, &state, NULL);
+  XtVaGetValues (button, XtNstate, &state, 0);
   *store = state;
 #endif /* HAVE_ATHENA */
 }
 
+
+/* Callback for the Cancel button on the Preferences dialog.
+ */
 static void
-res_cancel_cb (Widget button, XtPointer client_data, XtPointer call_data)
+prefs_cancel_cb (Widget button, XtPointer client_data, XtPointer call_data)
 {
-  saver_info *si = (saver_info *) client_data;
-  saver_preferences *p = &si->prefs;
-
-  XtDestroyWidget (resources_dialog);
-  resources_dialog = 0;
-  raise_screenhack_dialog ();
-
-  if (p->verbose_p)
-    fprintf (stderr, "%s: lowering preferences dialog.\n", blurb());
+  XtDestroyWidget (preferences_dialog);
+  preferences_dialog = 0;
+  XMapRaised (XtDisplay (demo_dialog), XtWindow (demo_dialog));
 }
 
 
+/* Callback for the OK button on the Preferences dialog.
+ */
 static void
-res_done_cb (Widget button, XtPointer client_data, XtPointer call_data)
+prefs_ok_cb (Widget button, XtPointer client_data, XtPointer call_data)
 {
-  saver_info *si = (saver_info *) client_data;
-  saver_preferences *p = &si->prefs;
+  prefs_pair *pair = (prefs_pair *) client_data;
+  saver_preferences *p =  pair->a;
+  saver_preferences *p2 = pair->b;
 
-  res_cancel_cb (button, client_data, call_data);
+  prefs_cancel_cb (button, 0, call_data);
 
 #ifdef HAVE_ATHENA
-  /* Check all text widgets, since we don't have callbacks for these. */
-  res_min_cb (timeout_text,     (XtPointer) &res.timeout,     NULL);
-  res_min_cb (cycle_text,       (XtPointer) &res.cycle,       NULL);
-  res_sec_cb (fade_text,        (XtPointer) &res.secs,        NULL);
-  res_int_cb (ticks_text,       (XtPointer) &res.ticks,       NULL);
-  res_min_cb (lock_time_text,   (XtPointer) &res.lock_time,   NULL);
-  res_sec_cb (passwd_time_text, (XtPointer) &res.passwd_time, NULL);
+  /* Athena doesn't let us put callbacks on these widgets, so run
+     all the callbacks by hand when OK is pressed. */
+  prefs_min_cb (timeout_text,        (XtPointer) &p2->timeout,        0);
+  prefs_min_cb (cycle_text,          (XtPointer) &p2->cycle,          0);
+  prefs_sec_cb (fade_text,           (XtPointer) &p2->fade_seconds,   0);
+  prefs_int_cb (fade_ticks_text,     (XtPointer) &p2->fade_ticks,     0);
+  prefs_min_cb (lock_timeout_text,   (XtPointer) &p2->lock_timeout,   0);
+  prefs_sec_cb (passwd_timeout_text, (XtPointer) &p2->passwd_timeout, 0);
 #endif /* HAVE_ATHENA */
 
-  /* Throttle the timeouts to minimum sane values. */
-  if (res.timeout < 5) res.timeout = 5;
-  if (res.cycle < 2) res.cycle = 2;
-  if (res.passwd_time < 10) res.passwd_time = 10;
-
-  p->timeout = res.timeout * 1000;
-  p->cycle = res.cycle * 1000;
-  p->lock_timeout = res.lock_time * 1000;
-#ifndef NO_LOCKING
-  p->passwd_timeout = res.passwd_time * 1000;
-#endif
-  p->fade_seconds = res.secs;
-  p->fade_ticks = res.ticks;
-  p->verbose_p = res.verb;
-  p->install_cmap_p = res.cmap;
-  p->fade_p = res.fade;
-  p->unfade_p = res.unfade;
-  p->lock_p = res.lock_p;
-
-  if (p->debug_p && p->verbose_p)
-    fprintf (stderr, "%s: parameters changed:\n\
-       timeout: %d\n\tcycle:   %d\n\tlock:    %d\n\tpasswd:  %d\n\
-       fade:    %d\n\tfade:    %d\n\tverbose: %d\n\tinstall: %d\n\
-       fade:    %d\n\tunfade:  %d\n\tlock:    %d\n",
-            blurb(), p->timeout, p->cycle, p->lock_timeout,
-#ifdef NO_LOCKING
-            0,
-#else
-            p->passwd_timeout,
-#endif
-            p->fade_seconds, p->fade_ticks, p->verbose_p, p->install_cmap_p,
-            p->fade_p, p->unfade_p, p->lock_p);
-
-
-#if defined(HAVE_MIT_SAVER_EXTENSION) || defined(HAVE_SGI_SAVER_EXTENSION)
-  if (p->use_mit_saver_extension || p->use_sgi_saver_extension)
-    {
-      /* Need to set the server timeout to the new one the user has picked.
-       */
-      int server_timeout, server_interval, prefer_blank, allow_exp;
-      XGetScreenSaver (si->dpy, &server_timeout, &server_interval,
-                      &prefer_blank, &allow_exp);
-      if (server_timeout != (p->timeout / 1000))
-       {
-         server_timeout = (p->timeout / 1000);
-         if (p->verbose_p)
-           fprintf (stderr,
-                  "%s: configuring server for saver timeout of %d seconds.\n",
-                    blurb(), server_timeout);
-         /* Leave all other parameters the same. */
-         XSetScreenSaver (si->dpy, server_timeout, server_interval,
-                          prefer_blank, allow_exp);
-       }
-    }
-#endif /* HAVE_MIT_SAVER_EXTENSION || HAVE_SGI_SAVER_EXTENSION */
-
-  write_init_file (si);
+  p->timeout       = p2->timeout;
+  p->cycle         = p2->cycle;
+  p->lock_timeout   = p2->lock_timeout;
+  p->passwd_timeout = p2->passwd_timeout;
+  p->fade_seconds   = p2->fade_seconds;
+  p->fade_ticks            = p2->fade_ticks;
+  p->verbose_p     = p2->verbose_p;
+  p->install_cmap_p = p2->install_cmap_p;
+  p->fade_p        = p2->fade_p;
+  p->unfade_p      = p2->unfade_p;
+  p->lock_p        = p2->lock_p;
+
+  write_init_file (p, short_version);
 }
 
 
 static void
-make_resources_dialog (saver_info *si, Widget parent)
+make_preferences_dialog (prefs_pair *pair, Widget parent)
 {
-  saver_screen_info *ssi = si->default_screen;
+  saver_preferences *p =  pair->a;
+  saver_preferences *p2 = pair->b;
 
-  if (ssi->demo_cmap &&
-      ssi->demo_cmap != ssi->cmap &&
-      ssi->demo_cmap != DefaultColormapOfScreen (ssi->screen))
-    {
-      XFreeColormap (si->dpy, ssi->demo_cmap);
-      ssi->demo_cmap = 0;
-    }
+  Screen *screen = XtScreen (parent);
+  Display *dpy = XtDisplay (parent);
 
-  if (ssi->default_visual == DefaultVisualOfScreen (ssi->screen))
-    ssi->demo_cmap = DefaultColormapOfScreen (ssi->screen);
-  else
-    ssi->demo_cmap = XCreateColormap (si->dpy,
-                                    RootWindowOfScreen (ssi->screen),
-                                    ssi->default_visual, AllocNone);
+  *p2 = *p;    /* copy all slots of p into p2. */
 
-  create_resources_dialog (parent, ssi->default_visual, ssi->demo_cmap);
+  create_preferences_dialog (parent,
+                            DefaultVisualOfScreen (screen),
+                            DefaultColormapOfScreen (screen));
 
-  add_button_callback (res_done,   res_done_cb,   (XtPointer) si);
-  add_button_callback (res_cancel, res_cancel_cb, (XtPointer) si);
+  add_button_callback (prefs_done,   prefs_ok_cb,     (XtPointer) pair);
+  add_button_callback (prefs_cancel, prefs_cancel_cb, 0);
 
 #define CB(widget,type,slot) \
        add_text_callback ((widget), (type), (XtPointer) (slot))
@@ -934,44 +855,55 @@ make_resources_dialog (saver_info *si, Widget parent)
 
 #ifdef HAVE_MOTIF
   /* When using Athena widgets, we can't set callbacks for these,
-     so we'll check them all if "done" gets pressed.
-   */
-  CB (timeout_text,    res_min_cb,  &res.timeout);
-  CB (cycle_text,      res_min_cb,  &res.cycle);
-  CB (fade_text,       res_sec_cb,  &res.secs);
-  CB (ticks_text,      res_int_cb,  &res.ticks);
-  CB (lock_time_text,  res_min_cb,  &res.lock_time);
-  CB (passwd_time_text,        res_sec_cb,  &res.passwd_time);
+     so in that case, we run them by hand when "OK" is pressed. */
+  CB (timeout_text,            prefs_min_cb,  &p2->timeout);
+  CB (cycle_text,              prefs_min_cb,  &p2->cycle);
+  CB (fade_text,               prefs_sec_cb,  &p2->fade_seconds);
+  CB (fade_ticks_text,         prefs_int_cb,  &p2->fade_ticks);
+  CB (lock_timeout_text,       prefs_min_cb,  &p2->lock_timeout);
+  CB (passwd_timeout_text,     prefs_sec_cb,  &p2->passwd_timeout);
 #endif /* HAVE_MOTIF */
 
-  CBT (verbose_toggle, res_bool_cb, &res.verb);
-  CBT (cmap_toggle,    res_bool_cb, &res.cmap);
-  CBT (fade_toggle,    res_bool_cb, &res.fade);
-  CBT (unfade_toggle,  res_bool_cb, &res.unfade);
-  CBT (lock_toggle,    res_bool_cb, &res.lock_p);
+  CBT (verbose_toggle,         prefs_bool_cb, &p2->verbose_p);
+  CBT (install_cmap_toggle,    prefs_bool_cb, &p2->install_cmap_p);
+  CBT (fade_toggle,            prefs_bool_cb, &p2->fade_p);
+  CBT (unfade_toggle,          prefs_bool_cb, &p2->unfade_p);
+  CBT (lock_toggle,            prefs_bool_cb, &p2->lock_p);
 #undef CB
 #undef CBT
 
-  if (si->locking_disabled_p)
-    {
-      disable_widget (passwd_time_text);
-      disable_widget (lock_time_text);
-      disable_widget (lock_toggle);
-    }
-  if (!si->fading_possible_p)
-    {
-      disable_widget (fade_text);
-      disable_widget (ticks_text);
-      disable_widget (cmap_toggle);
-      disable_widget (fade_toggle);
-      disable_widget (unfade_toggle);
-    }
+  {
+    Bool found_any_writable_cells = False;
+    int nscreens = ScreenCount(dpy);
+    int i;
+    for (i = 0; i < nscreens; i++)
+      {
+       Screen *s = ScreenOfDisplay (dpy, i);
+       if (has_writable_cells (s, DefaultVisualOfScreen (s)))
+         {
+           found_any_writable_cells = True;
+           break;
+         }
+      }
+
+    if (! found_any_writable_cells)    /* fading isn't possible */
+      {
+       disable_widget (fade_text);
+       disable_widget (fade_ticks_text);
+       disable_widget (install_cmap_toggle);
+       disable_widget (fade_toggle);
+       disable_widget (unfade_toggle);
+      }
+  }
 }
 
 
+/* Formats a `Time' into "H:MM:SS".  (Time is microseconds.)
+ */
 static void
-fmt_time (char *buf, unsigned int s, int min_p)
+format_time (char *buf, Time time)
 {
+  int s = time / 1000;
   unsigned int h = 0, m = 0;
   if (s >= 60)
     {
@@ -983,173 +915,406 @@ fmt_time (char *buf, unsigned int s, int min_p)
       h += (m / 60);
       m %= 60;
     }
-/*
-  if (min_p && h == 0 && s == 0)
-    sprintf (buf, "%u", m);
-  else if (!min_p && h == 0 && m == 0)
-    sprintf (buf, "%u", s);
-  else
-  if (h == 0)
-    sprintf (buf, "%u:%02u", m, s);
-  else
-*/
-    sprintf (buf, "%u:%02u:%02u", h, m, s);
+  sprintf (buf, "%u:%02u:%02u", h, m, s);
 }
 
+
 static void
-pop_resources_dialog (saver_info *si)
+pop_preferences_dialog (prefs_pair *pair)
 {
-  saver_preferences *p = &si->prefs;
-  char buf [100];
+  /* saver_preferences *p =  pair->a; */
+  saver_preferences *p2 = pair->b;
+  char s[100];
+
+  format_time (s, p2->timeout);        set_text_string(timeout_text, s);
+  format_time (s, p2->cycle);          set_text_string(cycle_text, s);
+  format_time (s, p2->lock_timeout);   set_text_string(lock_timeout_text, s);
+  format_time (s, p2->passwd_timeout); set_text_string(passwd_timeout_text, s);
+  format_time (s, p2->fade_seconds);   set_text_string(fade_text, s);
+  sprintf (s, "%u", p2->fade_ticks);   set_text_string(fade_ticks_text, s);
+
+  set_toggle_button_state (verbose_toggle,     p2->verbose_p);
+  set_toggle_button_state (install_cmap_toggle, p2->install_cmap_p);
+  set_toggle_button_state (fade_toggle,                p2->fade_p);
+  set_toggle_button_state (unfade_toggle,      p2->unfade_p);
+  set_toggle_button_state (lock_toggle,                p2->lock_p);
+
+  pop_up_dialog_box (preferences_dialog, preferences_form);
+}
 
-  if (p->verbose_p)
-    fprintf (stderr, "%s: raising preferences dialog.\n", blurb());
 
-  res.timeout = p->timeout / 1000;
-  res.cycle = p->cycle / 1000;
-  res.lock_time = p->lock_timeout / 1000;
-#ifndef NO_LOCKING
-  res.passwd_time = p->passwd_timeout / 1000;
-#endif
-  res.secs = p->fade_seconds;
-  res.ticks = p->fade_ticks;
-  res.verb = p->verbose_p;
-  res.cmap = p->install_cmap_p;
-  res.fade = p->fade_p;
-  res.unfade = p->unfade_p;
-  res.lock_p = (p->lock_p && !si->locking_disabled_p);
-
-  fmt_time (buf, res.timeout, 1);     set_text_string (timeout_text, buf);
-  fmt_time (buf, res.cycle, 1);       set_text_string (cycle_text, buf);
-  fmt_time (buf, res.lock_time, 1);   set_text_string (lock_time_text, buf);
-  fmt_time (buf, res.passwd_time, 0); set_text_string (passwd_time_text, buf);
-  fmt_time (buf, res.secs, 0);        set_text_string (fade_text, buf);
-  sprintf (buf, "%u", res.ticks);     set_text_string (ticks_text, buf);
-
-  set_toggle_button_state (verbose_toggle, res.verb);
-  set_toggle_button_state (cmap_toggle, res.cmap);
-  set_toggle_button_state (fade_toggle, res.fade);
-  set_toggle_button_state (unfade_toggle, res.unfade);
-  set_toggle_button_state (lock_toggle, res.lock_p);
-
-  monitor_power_on (si);
-  pop_up_dialog_box (resources_dialog, resources_form,
-                    /* for debugging -- don't ask */
-                    (si->prefs.debug_p ? 69 : 0) +
-                    1);
+static void
+run_hack (Display *dpy, int n)
+{
+  if (n <= 0) abort();
+  xscreensaver_command (dpy, XA_DEMO, n, False);
 }
 
-\f
-/* The main demo-mode command loop.
- */
 
-void
-demo_mode (saver_info *si)
+static void
+warning_dialog_dismiss_cb (Widget button, XtPointer client_data,
+                          XtPointer call_data)
 {
-  saver_preferences *p = &si->prefs;
-  Bool prefs_p = (si->demo_mode_p == (Bool) 2);  /* kludge! */
+  Widget shell = (Widget) client_data;
+  XtDestroyWidget (shell);
+}
 
-  if (p->verbose_p)
-    fprintf (stderr, "%s: Demo Mode.\n", blurb());
+static void
+warning_dialog (Widget parent, const char *message)
+{
+  char *msg = strdup (message);
+  char *head;
 
-  si->selection_mode = 0;
-  si->dbox_up_p = True;
-  monitor_power_on (si);
-  raise_window (si, True, False, False);
-  make_screenhack_dialog (si);
+  Widget dialog = 0;
+  Widget label = 0;
+  Widget ok = 0;
+  int i = 0;
 
-  if (prefs_p)
-    edit_cb (0, si, 0);                /* pop up preferences panel */
+#ifdef HAVE_MOTIF
 
-  while (si->demo_mode_p)
+  Widget w;
+  Widget container;
+  XmString xmstr;
+  Arg av[10];
+  int ac = 0;
+
+  ac = 0;
+  dialog = XmCreateWarningDialog (parent, "versionWarning", av, ac);
+
+  w = XmMessageBoxGetChild (dialog, XmDIALOG_MESSAGE_LABEL);
+  if (w) XtUnmanageChild (w);
+  w = XmMessageBoxGetChild (dialog, XmDIALOG_CANCEL_BUTTON);
+  if (w) XtUnmanageChild (w);
+  w = XmMessageBoxGetChild (dialog, XmDIALOG_HELP_BUTTON);
+  if (w) XtUnmanageChild (w);
+
+  ok = XmMessageBoxGetChild (dialog, XmDIALOG_OK_BUTTON);
+
+  ac = 0;
+  XtSetArg (av[ac], XmNnumColumns, 1); ac++;
+  XtSetArg (av[ac], XmNorientation, XmVERTICAL); ac++;
+  XtSetArg (av[ac], XmNpacking, XmPACK_COLUMN); ac++;
+  XtSetArg (av[ac], XmNrowColumnType, XmWORK_AREA); ac++;
+  XtSetArg (av[ac], XmNspacing, 0); ac++;
+  container = XmCreateRowColumn (dialog, "container", av, ac);
+
+#else  /* HAVE_ATHENA */
+
+  Widget form;
+  dialog = XtVaCreatePopupShell("warning_dialog", transientShellWidgetClass,
+                               parent, 0);
+  form = XtVaCreateManagedWidget("warning_form", formWidgetClass, dialog, 0);
+
+#endif /* HAVE_ATHENA */
+
+  head = msg;
+  while (head)
     {
-      XEvent event;
-      XtAppNextEvent (si->app, &event);
-      switch (event.xany.type)
-       {
-       case 0:         /* synthetic "timeout" event */
-         break;
-
-       case ClientMessage:
-         handle_clientmessage (si, &event, False);
-         break;
-
-       case CreateNotify:
-         if (!p->use_xidle_extension &&
-             !p->use_mit_saver_extension &&
-             !p->use_sgi_saver_extension)
-           {
-             start_notice_events_timer (si, event.xcreatewindow.window);
-#ifdef DEBUG_TIMERS
-             if (p->verbose_p)
-               fprintf (stderr,
-                        "%s: starting notice_events_timer for 0x%X (%lu)\n",
-                        blurb(),
-                        (unsigned int) event.xcreatewindow.window,
-                        p->notice_events_timeout);
-#endif /* DEBUG_TIMERS */
-           }
-         break;
-
-       case ButtonPress:
-       case ButtonRelease:
-         if (!XtWindowToWidget (si->dpy, event.xbutton.window))
-           raise_screenhack_dialog ();
-         /* fall through */
-
-       default:
-#ifdef HAVE_MIT_SAVER_EXTENSION
-         if (event.type == si->mit_saver_ext_event_number)
-           {
-             /* 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];
-                 if (ssi->server_mit_saver_window &&
-                     window_exists_p (si->dpy, ssi->server_mit_saver_window))
-                   XUnmapWindow (si->dpy, ssi->server_mit_saver_window);
-               }
-           }
-         else
-#endif /* HAVE_MIT_SAVER_EXTENSION */
-
-         XtDispatchEvent (&event);
-         break;
-       }
+      char name[20];
+      char *s = strchr (head, '\n');
+      if (s) *s = 0;
+
+      sprintf (name, "label%d", i++);
+
+#ifdef HAVE_MOTIF
+      xmstr = XmStringCreate (head, XmSTRING_DEFAULT_CHARSET);
+      ac = 0;
+      XtSetArg (av[ac], XmNlabelString, xmstr); ac++;
+      label = XmCreateLabelGadget (container, name, av, ac);
+      XtManageChild (label);
+      XmStringFree (xmstr);
+#else  /* HAVE_ATHENA */
+      
+      label = XtVaCreateManagedWidget (name, labelWidgetClass,
+                                      form,
+                                      XtNleft, XtChainLeft,
+                                      XtNright, XtChainRight,
+                                      XtNlabel, head,
+                                      (label ? XtNfromVert : XtNtop),
+                                      (label ? label : XtChainTop),
+                                      0);
+
+#endif /* HAVE_ATHENA */
+
+      if (s)
+       head = s+1;
+      else
+       head = 0;
     }
 
-  if (p->verbose_p)
-    fprintf (stderr, "%s: Demo Mode done.\n", blurb());
+#ifdef HAVE_MOTIF
+
+  XtManageChild (container);
+  XtRealizeWidget (dialog);
+  XtManageChild (dialog);
+
+#else  /* HAVE_ATHENA */
+
+  ok = XtVaCreateManagedWidget ("ok", commandWidgetClass, form,
+                               XtNleft, XtChainLeft,
+                               XtNbottom, XtChainBottom,
+                               XtNfromVert, label,
+                               0);
 
-  kill_screenhack (si);
+  XtRealizeWidget (dialog);
+  XtPopup (dialog, XtGrabNone);
 
-  destroy_screenhack_dialogs (si);
-  initialize_screensaver_window (si);
+#endif /* HAVE_ATHENA */
 
-  si->dbox_up_p = False;
-  si->demo_hack = 0;
+  add_button_callback (ok, warning_dialog_dismiss_cb, dialog);
 
-  si->demo_mode_p = True;  /* kludge to inhibit unfade... */
-  unblank_screen (si);
-  si->demo_mode_p = False;
+  free (msg);
 }
 
-static void
-demo_mode_hack (saver_info *si, char *hack)
+
+\f
+/* The main demo-mode command loop.
+ */
+
+#if 0
+static Bool
+mapper (XrmDatabase *db, XrmBindingList bindings, XrmQuarkList quarks,
+       XrmRepresentation *type, XrmValue *value, XPointer closure)
 {
-  if (! si->demo_mode_p) abort ();
-  kill_screenhack (si);
-  if (! si->demo_hack)
-    blank_screen (si);
-  si->demo_hack = hack;
-  spawn_screenhack (si, False);
-  /* raise_screenhack_dialog(); */
+  int i;
+  for (i = 0; quarks[i]; i++)
+    {
+      if (bindings[i] == XrmBindTightly)
+       fprintf (stderr, (i == 0 ? "" : "."));
+      else if (bindings[i] == XrmBindLoosely)
+       fprintf (stderr, "*");
+      else
+       fprintf (stderr, " ??? ");
+      fprintf(stderr, "%s", XrmQuarkToString (quarks[i]));
+    }
+
+  fprintf (stderr, ": %s\n", (char *) value->addr);
+
+  return False;
 }
+#endif
 
 static void
-demo_mode_done (saver_info *si)
+the_network_is_not_the_computer (Widget parent)
+{
+  Display *dpy = XtDisplay (parent);
+  char *rversion, *ruser, *rhost;
+  char *luser, *lhost;
+  char *msg = 0;
+  struct passwd *p = getpwuid (getuid ());
+  const char *d = DisplayString (dpy);
+
+# if defined(HAVE_UNAME)
+  struct utsname uts;
+  if (uname (&uts) < 0)
+    lhost = "<UNKNOWN>";
+  else
+    lhost = uts.nodename;
+# elif defined(VMS)
+  strcpy (lhost, getenv("SYS$NODE"));
+# else  /* !HAVE_UNAME && !VMS */
+  strcat (lhost, "<UNKNOWN>");
+# endif /* !HAVE_UNAME && !VMS */
+
+  if (p && p->pw_name)
+    luser = p->pw_name;
+  else
+    luser = "???";
+
+  server_xscreensaver_version (dpy, &rversion, &ruser, &rhost);
+
+  /* Make a buffer that's big enough for a number of copies of all the
+     strings, plus some. */
+  msg = (char *) malloc (10 * ((rversion ? strlen(rversion) : 0) +
+                              (ruser ? strlen(ruser) : 0) +
+                              (rhost ? strlen(rhost) : 0) +
+                              strlen(lhost) +
+                              strlen(luser) +
+                              strlen(d) +
+                              30));
+  *msg = 0;
+
+  if (!rversion || !*rversion)
+    {
+      sprintf (msg,
+              "Warning:\n\n"
+              "xscreensaver doesn't seem to be running on display \"%s\".",
+              d);
+    }
+  else if (p && ruser && *ruser && !!strcmp (ruser, p->pw_name))
+    {
+      /* Warn that the two processes are running as different users.
+       */
+      sprintf(msg,
+              "Warning:\n\n"
+             "%s is running as user \"%s\" on host \"%s\".\n"
+             "But the xscreensaver managing display \"%s\"\n"
+             "is running as user \"%s\" on host \"%s\".\n"
+             "\n"
+             "Since they are different users, they won't be reading/writing\n"
+             "the same ~/.xscreensaver file, so %s isn't\n"
+             "going to work right.\n"
+             "\n"
+             "Either re-run %s as \"%s\", or re-run\n"
+             "xscreensaver as \"%s\".\n",
+             progname, luser, lhost,
+             d,
+             (ruser ? ruser : "???"), (rhost ? rhost : "???"),
+             progname,
+             progname, (ruser ? ruser : "???"),
+             luser);
+    }
+  else if (rhost && *rhost && !!strcmp (rhost, lhost))
+    {
+      /* Warn that the two processes are running on different hosts.
+       */
+      sprintf (msg,
+              "Warning:\n\n"
+              "%s is running as user \"%s\" on host \"%s\".\n"
+              "But the xscreensaver managing display \"%s\"\n"
+              "is running as user \"%s\" on host \"%s\".\n"
+              "\n"
+              "If those two machines don't share a file system (that is,\n"
+              "if they don't see the same ~%s/.xscreensaver file) then\n"
+              "%s won't work right.",
+              progname, luser, lhost,
+              d,
+              (ruser ? ruser : "???"), (rhost ? rhost : "???"),
+              luser,
+              progname);
+    }
+  else if (!!strcmp (rversion, short_version))
+    {
+      /* Warn that the version numbers don't match.
+       */
+      sprintf (msg,
+              "Warning:\n\n"
+              "This is %s version %s.\n"
+              "But the xscreensaver managing display \"%s\"\n"
+              "is version %s.  This could cause problems.",
+              progname, short_version,
+              d,
+              rversion);
+    }
+
+
+  if (*msg)
+    warning_dialog (parent, msg);
+
+  free (msg);
+}
+
+
+static char *defaults[] = {
+#include "XScreenSaver_ad.h"
+ 0
+};
+
+int
+main (int argc, char **argv)
 {
-  si->demo_mode_p = False;
+  XtAppContext app;
+  prefs_pair Pair, *pair;
+  saver_preferences P, P2, *p, *p2;
+  Bool prefs = False;
+  int i;
+  Display *dpy;
+  Widget toplevel_shell;
+  char *real_progname = argv[0];
+  char *s;
+
+  s = strrchr (real_progname, '/');
+  if (s) real_progname = s+1;
+
+  p = &P;
+  p2 = &P2;
+  pair = &Pair;
+  pair->a = p;
+  pair->b = p2;
+  memset (p,  0, sizeof (*p));
+  memset (p2, 0, sizeof (*p2));
+
+  /* We must read exactly the same resources as xscreensaver.
+     That means we must have both the same progclass *and* progname,
+     at least as far as the resource database is concerned.  So,
+     put "xscreensaver" in argv[0] while initializing Xt.
+   */
+  argv[0] = "xscreensaver";
+
+  toplevel_shell = XtAppInitialize (&app, progclass, 0, 0, &argc, argv,
+                                   defaults, 0, 0);
+  dpy = XtDisplay (toplevel_shell);
+  db = XtDatabase (dpy);
+  XtGetApplicationNameAndClass (dpy, &progname, &progclass);
+
+  for (i = 1; i < argc; i++)
+    {
+      char *s = argv[i];
+      if (s[0] == '-' && s[1] == '-')
+       s++;
+      if (!strcmp (s, "-prefs"))
+       prefs = True;
+      else
+       {
+         fprintf (stderr, "usage: %s [ -display dpy-string ] [ -prefs ]\n",
+                  real_progname);
+         exit (1);
+       }
+    }
+
+  short_version = (char *) malloc (5);
+  memcpy (short_version, screensaver_id + 17, 4);
+  short_version [4] = 0;
+
+
+  /* Now that Xt has been initialized, we can set our `progname' variable
+     to something that makes more sense (like our "real" argv[0].)
+   */
+  progname = real_progname;
+
+
+  p->db = db;
+  p->fading_possible_p = True;
+  load_init_file (p);
+  *p2 = *p;
+
+#ifdef HAVE_ATHENA
+  global_prefs_kludge = p;     /* I hate C so much... */
+#endif /* HAVE_ATHENA */
+
+#if 0
+  {
+    XrmName name = { 0 };
+    XrmClass class = { 0 };
+    int count = 0;
+    XrmEnumerateDatabase (db, &name, &class, XrmEnumAllLevels, mapper,
+                         (XtPointer) &count);
+  }
+#endif
+
+
+  XA_VROOT = XInternAtom (dpy, "__SWM_VROOT", False);
+  XA_SCREENSAVER = XInternAtom (dpy, "SCREENSAVER", False);
+  XA_SCREENSAVER_VERSION = XInternAtom (dpy, "_SCREENSAVER_VERSION",False);
+  XA_SCREENSAVER_TIME = XInternAtom (dpy, "_SCREENSAVER_TIME", False);
+  XA_SCREENSAVER_ID = XInternAtom (dpy, "_SCREENSAVER_ID", False);
+  XA_SCREENSAVER_RESPONSE = XInternAtom (dpy, "_SCREENSAVER_RESPONSE", False);
+  XA_SELECT = XInternAtom (dpy, "SELECT", False);
+  XA_DEMO = XInternAtom (dpy, "DEMO", False);
+  XA_RESTART = XInternAtom (dpy, "RESTART", False);
+
+  make_demo_dialog (toplevel_shell, pair);
+
+  if (prefs)
+    {
+      make_preferences_dialog (pair, toplevel_shell);
+      pop_preferences_dialog (pair);
+    }
+
+  the_network_is_not_the_computer (preferences_dialog
+                                  ? preferences_dialog
+                                  : demo_dialog);
+
+  XtAppMainLoop(app);
+  exit (0);
 }
index 5b652b11e86a9afd75001c71c4b33f73ac0d441d..757a91eb2e4fbbe89041542197de4c6e3529d204 100644 (file)
 
 #include "visual.h"    /* for visual_depth() */
 
-Widget resources_dialog;
-Widget resources_form;
+Widget preferences_dialog;
+Widget preferences_form;
 Widget timeout_text;
 Widget cycle_text;
 Widget fade_text;
-Widget ticks_text;
-Widget lock_time_text;
-Widget passwd_time_text;
+Widget fade_ticks_text;
+Widget lock_timeout_text;
+Widget passwd_timeout_text;
 Widget verbose_toggle;
-Widget cmap_toggle;
+Widget install_cmap_toggle;
 Widget fade_toggle;
 Widget unfade_toggle;
 Widget lock_toggle;
-Widget res_done;
-Widget res_cancel;
+Widget prefs_done;
+Widget prefs_cancel;
 
 Widget demo_dialog;
 Widget demo_form;
@@ -68,41 +68,39 @@ static Widget buttonbox, textbox, okbox;
 
 
 void
-create_resources_dialog(Widget parent, Visual *visual, Colormap colormap)
+create_preferences_dialog(Widget parent, Visual *visual, Colormap colormap)
 {
   Widget rlabel;
   int depth = visual_depth(XtScreen(parent), visual);
 
-  resources_dialog = 
-    XtVaCreatePopupShell("resources_dialog", transientShellWidgetClass, parent,
-                        XtNtitle, NULL,
-                        XtNoverrideRedirect, TRUE,
+  preferences_dialog = 
+    XtVaCreatePopupShell("preferences_dialog", transientShellWidgetClass, parent,
                         XtNvisual, visual,
                         XtNcolormap, colormap,
                         XtNdepth, depth,
                         NULL);
 
-  resources_form =
-    XtVaCreateManagedWidget("resources_form", formWidgetClass,
-                           resources_dialog,
+  preferences_form =
+    XtVaCreateManagedWidget("preferences_form", formWidgetClass,
+                           preferences_dialog,
                         XtNvisual, visual,
                         XtNcolormap, colormap,
                         XtNdepth, depth,
                            NULL);
 
-  rlabel = XtVaCreateManagedWidget("label1", labelWidgetClass, resources_form,
+  rlabel = XtVaCreateManagedWidget("label1", labelWidgetClass, preferences_form,
                                   XtNleft, XtChainLeft,
                                   XtNright, XtChainRight,
                                   XtNtop, XtChainTop,
                                   NULL);
 
   textbox=
-    XtVaCreateManagedWidget("textbox", formWidgetClass, resources_form,
+    XtVaCreateManagedWidget("textbox", formWidgetClass, preferences_form,
                            XtNleft, XtChainLeft,
                            XtNfromVert, rlabel,
                            NULL);
   okbox=
-    XtVaCreateManagedWidget("textbox", boxWidgetClass, resources_form,
+    XtVaCreateManagedWidget("textbox", boxWidgetClass, preferences_form,
                            XtNleft, XtChainLeft,
                            XtNright, XtChainRight,
                            XtNfromVert, textbox,
@@ -127,29 +125,29 @@ create_resources_dialog(Widget parent, Visual *visual, Colormap colormap)
                            XtNfromVert, cycle_text,
                            NULL);
 
-  ticks_text =
+  fade_ticks_text =
     XtVaCreateManagedWidget("ticks", dialogWidgetClass, textbox,
                            XtNtop, XtChainTop,
                            XtNright, XtChainRight,
                            XtNfromHoriz, timeout_text,
                            NULL);
 
-  lock_time_text =
+  lock_timeout_text =
     XtVaCreateManagedWidget("lockTime", dialogWidgetClass, textbox,
-                           XtNfromVert, ticks_text,
+                           XtNfromVert, fade_ticks_text,
                            XtNright, XtChainRight,
                            XtNfromHoriz, cycle_text,
                            NULL);
 
-  passwd_time_text =
+  passwd_timeout_text =
     XtVaCreateManagedWidget("passwdTime", dialogWidgetClass, textbox,
-                           XtNfromVert, lock_time_text,
+                           XtNfromVert, lock_timeout_text,
                            XtNright, XtChainRight,
                            XtNfromHoriz, fade_text,
                            NULL);
 
   buttonbox=
-    XtVaCreateManagedWidget("buttonbox", boxWidgetClass, resources_form,
+    XtVaCreateManagedWidget("buttonbox", boxWidgetClass, preferences_form,
                            XtNfromVert, rlabel,
                            XtNfromHoriz, textbox,
                            XtNright, XtChainRight,
@@ -158,7 +156,7 @@ create_resources_dialog(Widget parent, Visual *visual, Colormap colormap)
   verbose_toggle =
     XtVaCreateManagedWidget("verbose", toggleWidgetClass, buttonbox,
                            NULL);
-  cmap_toggle =
+  install_cmap_toggle =
     XtVaCreateManagedWidget("cmap", toggleWidgetClass, buttonbox,
                            NULL);
   fade_toggle =
@@ -172,9 +170,9 @@ create_resources_dialog(Widget parent, Visual *visual, Colormap colormap)
                            NULL);
 
 
-  res_done = XtVaCreateManagedWidget("done", commandWidgetClass, okbox,
+  prefs_done = XtVaCreateManagedWidget("done", commandWidgetClass, okbox,
                                     NULL);
-  res_cancel = XtVaCreateManagedWidget("cancel", commandWidgetClass, okbox,
+  prefs_cancel = XtVaCreateManagedWidget("cancel", commandWidgetClass, okbox,
                                       NULL);
 }
 
@@ -186,8 +184,6 @@ create_demo_dialog(Widget parent, Visual *visual, Colormap colormap)
 
   demo_dialog = 
     XtVaCreatePopupShell("demo_dialog", transientShellWidgetClass, parent,
-                        XtNtitle, NULL,
-                        XtNoverrideRedirect, TRUE,
                         XtNvisual, visual,
                         XtNcolormap, colormap,
                         XtNdepth, depth,
@@ -195,9 +191,12 @@ create_demo_dialog(Widget parent, Visual *visual, Colormap colormap)
 
   demo_form =
     XtVaCreateManagedWidget("demo_form", formWidgetClass, demo_dialog,
-                        XtNvisual, visual,
-                        XtNcolormap, colormap,
-                        XtNdepth, depth,
+                           XtNvisual, visual,
+                           XtNcolormap, colormap,
+                           XtNdepth, depth,
+                           XtNleft, XtChainLeft,
+                           XtNright, XtChainRight,
+                           XtNtop, XtChainTop,
                            NULL);
 
   label1 = XtVaCreateManagedWidget("label1", labelWidgetClass, demo_form,
@@ -217,6 +216,7 @@ create_demo_dialog(Widget parent, Visual *visual, Colormap colormap)
                            XtNleft, XtChainLeft,
                            XtNright, XtChainRight,
                            XtNfromVert, label2,
+                           XtNresizable, True,
                            NULL);
   viewport =
     XtVaCreateManagedWidget("viewport", viewportWidgetClass, subform,
@@ -252,6 +252,8 @@ create_demo_dialog(Widget parent, Visual *visual, Colormap colormap)
   next = XtVaCreateManagedWidget("next", commandWidgetClass, box, NULL);
   prev = XtVaCreateManagedWidget("prev", commandWidgetClass, box, NULL);
   edit = XtVaCreateManagedWidget("edit", commandWidgetClass, box, NULL);
+#if 0
   restart = XtVaCreateManagedWidget("restart", commandWidgetClass, box, NULL);
+#endif
   done = XtVaCreateManagedWidget("done", commandWidgetClass, box, NULL);
 }
index 22aa97052c4b1c576926d52508c83c78d2a2f74f..930b7b72e91c89902d9d8aef28e9457a0f7d77d7 100644 (file)
 
 #include "visual.h"    /* for visual_depth() */
 
-Widget resources_dialog;
-Widget resources_form;
+Widget preferences_dialog;
+Widget preferences_form;
 Widget timeout_text;
 Widget cycle_text;
 Widget fade_text;
-Widget ticks_text;
-Widget lock_time_text;
-Widget passwd_time_text;
+Widget fade_ticks_text;
+Widget lock_timeout_text;
+Widget passwd_timeout_text;
 Widget verbose_toggle;
-Widget cmap_toggle;
+Widget install_cmap_toggle;
 Widget fade_toggle;
 Widget unfade_toggle;
 Widget lock_toggle;
-Widget res_done;
-Widget res_cancel;
+Widget prefs_done;
+Widget prefs_cancel;
 
 Widget demo_dialog;
 Widget demo_form;
@@ -72,7 +72,7 @@ Widget restart;
 Widget spacer;
 
 void
-create_resources_dialog(Widget parent, Visual *visual, Colormap colormap)
+create_preferences_dialog(Widget parent, Visual *visual, Colormap colormap)
 {
   Widget children[22];      /* Children to manage */
   Arg al[64];           /* Arg List */
@@ -95,8 +95,8 @@ create_resources_dialog(Widget parent, Visual *visual, Colormap colormap)
   XtSetArg (al[ac], XmNcolormap, colormap); ac++;
   XtSetArg (al[ac], XmNdepth, visual_depth(XtScreen(parent), visual)); ac++;
 
-  real_dialog = XmCreatePromptDialog (parent, "resourcesForm", al, ac);
-  resources_dialog = XtParent(real_dialog);
+  real_dialog = XmCreatePromptDialog (parent, "preferencesForm", al, ac);
+  preferences_dialog = XtParent(real_dialog);
 
   w = XmSelectionBoxGetChild (real_dialog, XmDIALOG_SEPARATOR);
   if (w) XtUnmanageChild (w);
@@ -112,56 +112,56 @@ create_resources_dialog(Widget parent, Visual *visual, Colormap colormap)
   XtSetArg (al [ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
   XtSetArg (al [ac], XmNleftAttachment, XmATTACH_FORM); ac++;
   XtSetArg (al [ac], XmNrightAttachment, XmATTACH_FORM); ac++;
-  resources_form = XmCreateForm (real_dialog, "form", al, ac);
-  XtManageChild (resources_form);
+  preferences_form = XmCreateForm (real_dialog, "form", al, ac);
+  XtManageChild (preferences_form);
 
   ac = 0;
 
-  widget12 = XmCreateLabel ( resources_form, "resourcesLabel", al, ac );
-  widget13 = XmCreateSeparator ( resources_form, "separator", al, ac );
+  widget12 = XmCreateLabel ( preferences_form, "preferencesLabel", al, ac );
+  widget13 = XmCreateSeparator ( preferences_form, "separator", al, ac );
   XtSetArg(al[ac], XmNalignment, XmALIGNMENT_END); ac++;
-  widget14 = XmCreateLabel ( resources_form, "timeoutLabel", al, ac );
+  widget14 = XmCreateLabel ( preferences_form, "timeoutLabel", al, ac );
   ac = 0;
   XtSetArg(al[ac], XmNalignment, XmALIGNMENT_END); ac++;
-  widget15 = XmCreateLabel ( resources_form, "cycleLabel", al, ac );
+  widget15 = XmCreateLabel ( preferences_form, "cycleLabel", al, ac );
   ac = 0;
   XtSetArg(al[ac], XmNalignment, XmALIGNMENT_END); ac++;
-  widget16 = XmCreateLabel ( resources_form, "fadeSecondsLabel", al, ac );
+  widget16 = XmCreateLabel ( preferences_form, "fadeSecondsLabel", al, ac );
   ac = 0;
   XtSetArg(al[ac], XmNalignment, XmALIGNMENT_END); ac++;
-  widget17 = XmCreateLabel ( resources_form, "fadeTicksLabel", al, ac );
+  widget17 = XmCreateLabel ( preferences_form, "fadeTicksLabel", al, ac );
   ac = 0;
   XtSetArg(al[ac], XmNalignment, XmALIGNMENT_END); ac++;
-  widget18 = XmCreateLabel ( resources_form, "lockLabel", al, ac );
+  widget18 = XmCreateLabel ( preferences_form, "lockLabel", al, ac );
   ac = 0;
   XtSetArg(al[ac], XmNalignment, XmALIGNMENT_END); ac++;
-  widget48 = XmCreateLabel ( resources_form, "passwdLabel", al, ac );
-  ac = 0;
-  timeout_text = XmCreateTextField ( resources_form, "timeoutText", al, ac );
-  cycle_text = XmCreateTextField ( resources_form, "cycleText", al, ac );
-  fade_text = XmCreateTextField ( resources_form, "fadeSecondsText", al, ac );
-  ticks_text = XmCreateTextField ( resources_form, "fadeTicksText", al, ac );
-  lock_time_text = XmCreateTextField ( resources_form, "passwdText", al, ac );
-  passwd_time_text = XmCreateTextField ( resources_form, "lockText", al, ac );
+  widget48 = XmCreateLabel ( preferences_form, "passwdLabel", al, ac );
+  ac = 0;
+  timeout_text = XmCreateTextField ( preferences_form, "timeoutText", al, ac );
+  cycle_text = XmCreateTextField ( preferences_form, "cycleText", al, ac );
+  fade_text = XmCreateTextField ( preferences_form, "fadeSecondsText", al, ac);
+  fade_ticks_text = XmCreateTextField ( preferences_form, "fadeTicksText", al, ac);
+  lock_timeout_text = XmCreateTextField ( preferences_form, "passwdText", al, ac);
+  passwd_timeout_text = XmCreateTextField ( preferences_form, "lockText", al, ac);
   XtSetArg(al[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
-  verbose_toggle = XmCreateToggleButton ( resources_form, "verboseToggle", al, ac );
+  verbose_toggle = XmCreateToggleButton (preferences_form,"verboseToggle",al,ac);
   ac = 0;
   XtSetArg(al[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
-  cmap_toggle = XmCreateToggleButton ( resources_form, "cmapToggle", al, ac );
+  install_cmap_toggle = XmCreateToggleButton ( preferences_form, "cmapToggle", al, ac);
   ac = 0;
   XtSetArg(al[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
-  fade_toggle = XmCreateToggleButton ( resources_form, "fadeToggle", al, ac );
+  fade_toggle = XmCreateToggleButton ( preferences_form, "fadeToggle", al, ac);
   ac = 0;
   XtSetArg(al[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
-  unfade_toggle = XmCreateToggleButton ( resources_form, "unfadeToggle", al, ac );
+  unfade_toggle = XmCreateToggleButton (preferences_form,"unfadeToggle",al,ac);
   ac = 0;
   XtSetArg(al[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
-  lock_toggle = XmCreateToggleButton ( resources_form, "lockToggle", al, ac );
+  lock_toggle = XmCreateToggleButton ( preferences_form, "lockToggle", al, ac);
   ac = 0;
-  widget29 = XmCreateSeparator ( resources_form, "separator", al, ac );
+  widget29 = XmCreateSeparator ( preferences_form, "separator", al, ac );
 
-  res_done = XmSelectionBoxGetChild (real_dialog, XmDIALOG_OK_BUTTON);
-  res_cancel = XmSelectionBoxGetChild (real_dialog, XmDIALOG_CANCEL_BUTTON);
+  prefs_done = XmSelectionBoxGetChild (real_dialog, XmDIALOG_OK_BUTTON);
+  prefs_cancel = XmSelectionBoxGetChild (real_dialog, XmDIALOG_CANCEL_BUTTON);
 
   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
   XtSetArg(al[ac], XmNtopOffset, 4); ac++;
@@ -226,43 +226,43 @@ create_resources_dialog(Widget parent, Visual *visual, Colormap colormap)
 
   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
   XtSetArg(al[ac], XmNtopOffset, 0); ac++;
-  XtSetArg(al[ac], XmNtopWidget, ticks_text); ac++;
+  XtSetArg(al[ac], XmNtopWidget, fade_ticks_text); ac++;
   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
   XtSetArg(al[ac], XmNbottomOffset, 0); ac++;
-  XtSetArg(al[ac], XmNbottomWidget, ticks_text); ac++;
+  XtSetArg(al[ac], XmNbottomWidget, fade_ticks_text); ac++;
   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
   XtSetArg(al[ac], XmNleftOffset, 20); ac++;
   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
   XtSetArg(al[ac], XmNrightOffset, 4); ac++;
-  XtSetArg(al[ac], XmNrightWidget, ticks_text); ac++;
+  XtSetArg(al[ac], XmNrightWidget, fade_ticks_text); ac++;
   XtSetValues ( widget17,al, ac );
   ac = 0;
 
   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
   XtSetArg(al[ac], XmNtopOffset, 0); ac++;
-  XtSetArg(al[ac], XmNtopWidget, lock_time_text); ac++;
+  XtSetArg(al[ac], XmNtopWidget, lock_timeout_text); ac++;
   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
   XtSetArg(al[ac], XmNbottomOffset, 0); ac++;
-  XtSetArg(al[ac], XmNbottomWidget, lock_time_text); ac++;
+  XtSetArg(al[ac], XmNbottomWidget, lock_timeout_text); ac++;
   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
   XtSetArg(al[ac], XmNleftOffset, 19); ac++;
   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
   XtSetArg(al[ac], XmNrightOffset, 4); ac++;
-  XtSetArg(al[ac], XmNrightWidget, lock_time_text); ac++;
+  XtSetArg(al[ac], XmNrightWidget, lock_timeout_text); ac++;
   XtSetValues ( widget18,al, ac );
   ac = 0;
 
   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
   XtSetArg(al[ac], XmNtopOffset, 0); ac++;
-  XtSetArg(al[ac], XmNtopWidget, passwd_time_text); ac++;
+  XtSetArg(al[ac], XmNtopWidget, passwd_timeout_text); ac++;
   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
   XtSetArg(al[ac], XmNbottomOffset, 0); ac++;
-  XtSetArg(al[ac], XmNbottomWidget, passwd_time_text); ac++;
+  XtSetArg(al[ac], XmNbottomWidget, passwd_timeout_text); ac++;
   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
   XtSetArg(al[ac], XmNleftOffset, 14); ac++;
   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
   XtSetArg(al[ac], XmNrightOffset, 4); ac++;
-  XtSetArg(al[ac], XmNrightWidget, passwd_time_text); ac++;
+  XtSetArg(al[ac], XmNrightWidget, passwd_timeout_text); ac++;
   XtSetValues ( widget48,al, ac );
   ac = 0;
 
@@ -306,29 +306,29 @@ create_resources_dialog(Widget parent, Visual *visual, Colormap colormap)
   XtSetArg(al[ac], XmNleftOffset, 0); ac++;
   XtSetArg(al[ac], XmNleftWidget, fade_text); ac++;
   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
-  XtSetValues ( ticks_text,al, ac );
+  XtSetValues ( fade_ticks_text,al, ac );
   ac = 0;
 
   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
   XtSetArg(al[ac], XmNtopOffset, 2); ac++;
-  XtSetArg(al[ac], XmNtopWidget, ticks_text); ac++;
+  XtSetArg(al[ac], XmNtopWidget, fade_ticks_text); ac++;
   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
   XtSetArg(al[ac], XmNleftOffset, 0); ac++;
-  XtSetArg(al[ac], XmNleftWidget, ticks_text); ac++;
+  XtSetArg(al[ac], XmNleftWidget, fade_ticks_text); ac++;
   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
-  XtSetValues ( lock_time_text,al, ac );
+  XtSetValues ( lock_timeout_text,al, ac );
   ac = 0;
 
   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
   XtSetArg(al[ac], XmNtopOffset, 4); ac++;
-  XtSetArg(al[ac], XmNtopWidget, lock_time_text); ac++;
+  XtSetArg(al[ac], XmNtopWidget, lock_timeout_text); ac++;
   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
   XtSetArg(al[ac], XmNleftOffset, 0); ac++;
-  XtSetArg(al[ac], XmNleftWidget, lock_time_text); ac++;
+  XtSetArg(al[ac], XmNleftWidget, lock_timeout_text); ac++;
   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
-  XtSetValues ( passwd_time_text,al, ac );
+  XtSetValues ( passwd_timeout_text,al, ac );
   ac = 0;
 
   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
@@ -356,7 +356,7 @@ create_resources_dialog(Widget parent, Visual *visual, Colormap colormap)
   XtSetArg(al[ac], XmNleftWidget, verbose_toggle); ac++;
   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
   XtSetArg(al[ac], XmNrightOffset, 20); ac++;
-  XtSetValues ( cmap_toggle,al, ac );
+  XtSetValues ( install_cmap_toggle,al, ac );
   ac = 0;
 
   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
@@ -367,7 +367,7 @@ create_resources_dialog(Widget parent, Visual *visual, Colormap colormap)
   XtSetArg(al[ac], XmNbottomWidget, fade_text); ac++;
   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
   XtSetArg(al[ac], XmNleftOffset, 0); ac++;
-  XtSetArg(al[ac], XmNleftWidget, cmap_toggle); ac++;
+  XtSetArg(al[ac], XmNleftWidget, install_cmap_toggle); ac++;
   XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
   XtSetArg(al[ac], XmNrightOffset, 20); ac++;
   XtSetValues ( fade_toggle,al, ac );
@@ -375,10 +375,10 @@ create_resources_dialog(Widget parent, Visual *visual, Colormap colormap)
 
   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
   XtSetArg(al[ac], XmNtopOffset, 0); ac++;
-  XtSetArg(al[ac], XmNtopWidget, ticks_text); ac++;
+  XtSetArg(al[ac], XmNtopWidget, fade_ticks_text); ac++;
   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
   XtSetArg(al[ac], XmNbottomOffset, 0); ac++;
-  XtSetArg(al[ac], XmNbottomWidget, ticks_text); ac++;
+  XtSetArg(al[ac], XmNbottomWidget, fade_ticks_text); ac++;
   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
   XtSetArg(al[ac], XmNleftOffset, 0); ac++;
   XtSetArg(al[ac], XmNleftWidget, fade_toggle); ac++;
@@ -389,10 +389,10 @@ create_resources_dialog(Widget parent, Visual *visual, Colormap colormap)
 
   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
   XtSetArg(al[ac], XmNtopOffset, 0); ac++;
-  XtSetArg(al[ac], XmNtopWidget, lock_time_text); ac++;
+  XtSetArg(al[ac], XmNtopWidget, lock_timeout_text); ac++;
   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
   XtSetArg(al[ac], XmNbottomOffset, 0); ac++;
-  XtSetArg(al[ac], XmNbottomWidget, lock_time_text); ac++;
+  XtSetArg(al[ac], XmNbottomWidget, lock_timeout_text); ac++;
   XtSetArg(al[ac], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
   XtSetArg(al[ac], XmNleftOffset, 0); ac++;
   XtSetArg(al[ac], XmNleftWidget, unfade_toggle); ac++;
@@ -403,7 +403,7 @@ create_resources_dialog(Widget parent, Visual *visual, Colormap colormap)
 
   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
   XtSetArg(al[ac], XmNtopOffset, 0); ac++;
-  XtSetArg(al[ac], XmNtopWidget, passwd_time_text); ac++;
+  XtSetArg(al[ac], XmNtopWidget, passwd_timeout_text); ac++;
 
   XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
   XtSetArg(al[ac], XmNbottomOffset, 4); ac++;
@@ -427,11 +427,11 @@ create_resources_dialog(Widget parent, Visual *visual, Colormap colormap)
   children[ac++] = timeout_text;
   children[ac++] = cycle_text;
   children[ac++] = fade_text;
-  children[ac++] = ticks_text;
-  children[ac++] = lock_time_text;
-  children[ac++] = passwd_time_text;
+  children[ac++] = fade_ticks_text;
+  children[ac++] = lock_timeout_text;
+  children[ac++] = passwd_timeout_text;
   children[ac++] = verbose_toggle;
-  children[ac++] = cmap_toggle;
+  children[ac++] = install_cmap_toggle;
   children[ac++] = fade_toggle;
   children[ac++] = unfade_toggle;
   children[ac++] = lock_toggle;
@@ -440,7 +440,7 @@ create_resources_dialog(Widget parent, Visual *visual, Colormap colormap)
   XtManageChildren(children, ac);
   ac = 0;
 
-  resources_form = real_dialog;
+  preferences_form = real_dialog;
 }
 
 
@@ -522,12 +522,16 @@ create_demo_dialog(Widget parent, Visual *visual, Colormap colormap)
   prev = XmCreatePushButton ( real_dialog, "prev", al, ac );
   edit = XmCreatePushButton ( real_dialog, "edit", al, ac );
   done = XmCreatePushButton ( real_dialog, "done", al, ac );
+#if 0
   restart = XmCreatePushButton ( real_dialog, "restart", al, ac );
+#endif
   XtManageChild(next);
   XtManageChild(prev);
   XtManageChild(edit);
   XtManageChild(done);
+#if 0
   XtManageChild(restart);
+#endif
 
   ac = 0;
   XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
diff --git a/driver/dotfile.c b/driver/dotfile.c
deleted file mode 100644 (file)
index cba794b..0000000
+++ /dev/null
@@ -1,698 +0,0 @@
-/* dotfile.c --- management of the ~/.xscreensaver file.
- * xscreensaver, Copyright (c) 1998 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
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation.  No representations are made about the suitability of this
- * software for any purpose.  It is provided "as is" without express or 
- * implied warranty.
- */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <X11/Xlib.h>
-#include <X11/Xresource.h>
-
-#ifndef VMS
-# include <pwd.h>
-#else /* VMS */
-# include "vms-pwd.h"
-#endif /* VMS */
-
-
-/* This file doesn't need the Xt headers, so stub these types out... */
-#undef XtPointer
-#define XtAppContext void*
-#define XtIntervalId void*
-#define XtPointer    void*
-#define Widget       void*
-
-#include "xscreensaver.h"
-#include "resources.h"
-
-/* Just in case there's something pathological about stat.h... */
-#ifndef  S_IRUSR
-# define S_IRUSR 00400
-#endif
-#ifndef  S_IWUSR
-# define S_IWUSR 00200
-#endif
-#ifndef  S_IXUSR
-# define S_IXUSR 00100
-#endif
-#ifndef  S_IXGRP
-# define S_IXGRP 00010
-#endif
-#ifndef  S_IXOTH
-# define S_IXOTH 00001
-#endif
-
-
-static const char *
-init_file_name (void)
-{
-  static char *file = 0;
-
-  if (!file)
-    {
-      struct passwd *p = getpwuid (getuid ());
-
-      if (!p || !p->pw_name || !*p->pw_name)
-       {
-         fprintf (stderr, "%s: couldn't get user info of uid %d\n",
-                  blurb(), getuid ());
-         file = "";
-       }
-      else if (!p->pw_dir || !*p->pw_dir)
-       {
-         fprintf (stderr, "%s: couldn't get home directory of %s\n",
-                  blurb(), (p->pw_name ? p->pw_name : "???"));
-         file = "";
-       }
-      else
-       {
-         const char *home = p->pw_dir;
-         const char *name = ".xscreensaver";
-         file = (char *) malloc(strlen(home) + strlen(name) + 2);
-         strcpy(file, home);
-         if (!*home || home[strlen(home)-1] != '/')
-           strcat(file, "/");
-         strcat(file, name);
-       }
-    }
-
-  if (file && *file)
-    return file;
-  else
-    return 0;
-}
-
-
-static const char *
-init_file_tmp_name (void)
-{
-  static char *file = 0;
-  if (!file)
-    {
-      const char *name = init_file_name();
-      const char *suffix = ".tmp";
-      if (!name || !*name)
-       file = "";
-      else
-       {
-         file = (char *) malloc(strlen(name) + strlen(suffix) + 2);
-         strcpy(file, name);
-         strcat(file, suffix);
-       }
-    }
-
-  if (file && *file)
-    return file;
-  else
-    return 0;
-}
-
-
-static const char * const prefs[] = {
-  "timeout",
-  "cycle",
-  "lock",
-  "lockVTs",
-  "lockTimeout",
-  "passwdTimeout",
-  "visualID",
-  "installColormap",
-  "verbose",
-  "timestamp",
-  "splash",                    /* not saved -- same as "splashDuration: 0" */
-  "splashDuration",
-  "helpURL",
-  "loadURL",
-  "nice",
-  "fade",
-  "unfade",
-  "fadeSeconds",
-  "fadeTicks",
-  "captureStderr",
-  "captureStdout",             /* not saved -- obsolete */
-  "font",
-  "",
-  "programs",
-  "",
-  "pointerPollTime",
-  "windowCreationTimeout",
-  "initialDelay",
-  "sgiSaverExtension",
-  "mitSaverExtension",
-  "xidleExtension",
-  "overlayStderr",
-  "overlayTextBackground",     /* not saved -- X resources only */
-  "overlayTextForeground",     /* not saved -- X resources only */
-  "bourneShell",               /* not saved -- X resources only */
-  0
-};
-
-static char *strip(char *s)
-{
-  char *s2;
-  while (*s == '\t' || *s == ' ' || *s == '\r' || *s == '\n')
-    s++;
-  for (s2 = s; *s2; s2++)
-    ;
-  for (s2--; s2 >= s; s2--) 
-    if (*s2 == '\t' || *s2 == ' ' || *s2 == '\r' || *s2 =='\n') 
-      *s2 = 0;
-    else
-      break;
-  return s;
-}
-
-\f
-/* Reading
- */
-
-static int
-handle_entry (saver_info *si, const char *key, const char *value,
-             const char *filename, int line)
-{
-  int i;
-  for (i = 0; prefs[i]; i++)
-    if (*prefs[i] && !strcasecmp(key, prefs[i]))
-      {
-       char *val = strdup(value);
-       char *spec = (char *) malloc(strlen(progclass) + strlen(prefs[i]) +10);
-       strcpy(spec, progclass);
-       strcat(spec, ".");
-       strcat(spec, prefs[i]);
-
-       XrmPutStringResource (&si->db, spec, val);
-
-       free(spec);
-       free(val);
-       return 0;
-      }
-
-  fprintf(stderr, "%s: %s:%d: unknown option \"%s\"\n",
-         blurb(), filename, line, key);
-  return 1;
-}
-
-int
-read_init_file (saver_info *si)
-{
-  time_t write_date = 0;
-  const char *name = init_file_name();
-  int line = 0;
-  struct stat st;
-  FILE *in;
-  int buf_size = 1024;
-  char *buf;
-
-  if (!name) return 0;
-
-  if (stat(name, &st) != 0)
-    {
-      si->init_file_date = 0;
-      return 0;
-    }
-
-  in = fopen(name, "r");
-  if (!in)
-    {
-      char *buf = (char *) malloc(1024 + strlen(name));
-      sprintf(buf, "%s: error reading %s", blurb(), name);
-      perror(buf);
-      free(buf);
-      return -1;
-    }
-
-  if (fstat (fileno(in), &st) == 0)
-    {
-      write_date = st.st_mtime;
-    }
-  else
-    {
-      char *buf = (char *) malloc(1024 + strlen(name));
-      sprintf(buf, "%s: couldn't re-stat %s", blurb(), name);
-      perror(buf);
-      free(buf);
-      return -1;
-    }
-
-  buf = (char *) malloc(buf_size);
-
-  while (fgets (buf, buf_size-1, in))
-    {
-      char *key, *value;
-      int L = strlen(buf);
-
-      line++;
-      while (L > 2 &&
-            (buf[L-1] != '\n' ||       /* whole line didn't fit in buffer */
-             buf[L-2] == '\\'))        /* or line ended with backslash */
-       {
-         if (buf[L-2] == '\\')         /* backslash-newline gets swallowed */
-           {
-             buf[L-2] = 0;
-             L -= 2;
-           }
-         buf_size += 1024;
-         buf = (char *) realloc(buf, buf_size);
-         if (!buf) exit(1);
-
-         line++;
-         if (!fgets (buf + L, buf_size-L-1, in))
-           break;
-         L = strlen(buf);
-       }
-
-      /* Now handle other backslash escapes. */
-      {
-       int i, j;
-       for (i = 0; buf[i]; i++)
-         if (buf[i] == '\\')
-           {
-             switch (buf[i+1])
-               {
-               case 'n': buf[i] = '\n'; break;
-               case 'r': buf[i] = '\r'; break;
-               case 't': buf[i] = '\t'; break;
-               default:  buf[i] = buf[i+1]; break;
-               }
-             for (j = i+2; buf[j]; j++)
-               buf[j-1] = buf[j];
-             buf[j-1] = 0;
-           }
-      }
-
-      key = strip(buf);
-
-      if (*key == '#' || *key == '!' || *key == ';' ||
-         *key == '\n' || *key == 0)
-       continue;
-
-      value = strchr (key, ':');
-      if (!value)
-       {
-         fprintf(stderr, "%s: %s:%d: unparsable line: %s\n", blurb(),
-                 name, line, key);
-         continue;
-       }
-      else
-       {
-         *value++ = 0;
-         value = strip(value);
-       }
-
-      handle_entry (si, key, value, name, line);
-    }
-  free(buf);
-
-  si->init_file_date = write_date;
-  return 0;
-}
-
-
-int
-maybe_reload_init_file (saver_info *si)
-{
-  saver_preferences *p = &si->prefs;
-  const char *name = init_file_name();
-  struct stat st;
-  int status = 0;
-
-  if (!name) return 0;
-
-  if (stat(name, &st) != 0)
-    return 0;
-
-  if (si->init_file_date == st.st_mtime)
-    return 0;
-
-  if (p->verbose_p)
-    fprintf (stderr, "%s: file %s has changed, reloading.\n", blurb(), name);
-
-  status = read_init_file (si);
-  if (status == 0)
-    get_resources (si);
-  return status;
-}
-
-\f
-/* Writing
- */
-
-static int
-tab_to (FILE *out, int from, int to)
-{
-  int tab_width = 8;
-  int to_mod = (to / tab_width) * tab_width;
-  while (from < to_mod)
-    {
-      fprintf(out, "\t");
-      from = (((from / tab_width) + 1) * tab_width);
-    }
-  while (from < to)
-    {
-      fprintf(out, " ");
-      from++;
-    }
-  return from;
-}
-
-static void
-write_entry (FILE *out, const char *key, const char *value)
-{
-  char *v = strdup(value ? value : "");
-  char *v2 = v;
-  char *nl = 0;
-  int col;
-  Bool do_visual_kludge = (!strcmp(key, "programs"));
-  Bool do_wrap = do_visual_kludge;
-  int tab = (do_visual_kludge ? 16 : 23);
-  int tab2 = 3;
-  Bool first = True;
-
-  fprintf(out, "%s:", key);
-  col = strlen(key) + 1;
-
-  while (1)
-    {
-      char *s;
-      if (first)
-       first = False;
-      else
-       {
-         col = tab_to(out, col, 75);
-         fprintf(out, " \\n\\\n");
-         col = 0;
-       }
-
-      v2 = strip(v2);
-      nl = strchr(v2, '\n');
-      if (nl)
-       *nl = 0;
-
-      s = (do_visual_kludge ? strpbrk(v2, " \t\n:") : 0);
-      if (s && *s == ':')
-       col = tab_to (out, col, tab2);
-      else
-       col = tab_to (out, col, tab);
-
-      if (do_wrap &&
-         strlen(v2) + col > 75)
-       {
-         int L = strlen(v2);
-         int start = 0;
-         int end = start;
-         while (start < L)
-           {
-             while (v2[end] == ' ' || v2[end] == '\t')
-               end++;
-             while (v2[end] != ' ' && v2[end] != '\t' &&
-                    v2[end] != '\n' && v2[end] != 0)
-               end++;
-             if (col + (end - start) >= 74)
-               {
-                 col = tab_to (out, col, 75);
-                 fprintf(out, "   \\\n");
-                 col = tab_to (out, 0, tab + 2);
-                 while (v2[start] == ' ' || v2[start] == '\t')
-                   start++;
-               }
-
-             while (start < end)
-               {
-                 fputc(v2[start++], out);
-                 col++;
-               }
-           }
-       }
-      else
-       {
-         fprintf (out, "%s", v2);
-         col += strlen(v2);
-       }
-
-      if (nl)
-       v2 = nl + 1;
-      else
-       break;
-    }
-
-  fprintf(out, "\n");
-  free(v);
-}
-
-int
-write_init_file (saver_info *si)
-{
-  const char *name = init_file_name();
-  const char *tmp_name = init_file_tmp_name();
-  struct stat st;
-  saver_preferences *p = &si->prefs;
-  int i, j;
-
-  /* Kludge, since these aren't in the saver_preferences struct as strings...
-   */
-  char *visual_name;
-  char *programs;
-  Bool capture_stderr_p;
-  Bool overlay_stderr_p;
-  char *stderr_font;
-  FILE *out;
-
-  if (!name) return 0;
-
-  if (si->dangerous_uid_p)
-    {
-      if (p->verbose_p)
-       {
-         fprintf (stderr, "%s: not writing \"%s\":\n", blurb(), name);
-         describe_uids (si, stderr);
-       }
-      return 0;
-    }
-
-  if (p->verbose_p)
-    fprintf (stderr, "%s: writing \"%s\".\n", blurb(), name);
-
-  unlink (tmp_name);
-  out = fopen(tmp_name, "w");
-  if (!out)
-    {
-      char *buf = (char *) malloc(1024 + strlen(name));
-      sprintf(buf, "%s: error writing %s", blurb(), name);
-      perror(buf);
-      free(buf);
-      return -1;
-    }
-
-  /* Give the new .xscreensaver file the same permissions as the old one;
-     except ensure that it is readable and writable by owner, and not
-     executable.
-   */
-  if (stat(name, &st) == 0)
-    {
-      mode_t mode = st.st_mode;
-      mode |= S_IRUSR | S_IWUSR;
-      mode &= ~(S_IXUSR | S_IXGRP | S_IXOTH);
-      if (fchmod (fileno(out), mode) != 0)
-       {
-         char *buf = (char *) malloc(1024 + strlen(name));
-         sprintf (buf, "%s: error fchmodding %s to 0%o", blurb(),
-                  tmp_name, (unsigned int) mode);
-         perror(buf);
-         free(buf);
-         return -1;
-       }
-    }
-
-  /* Kludge, since these aren't in the saver_preferences struct... */
-  visual_name = get_string_resource ("visualID", "VisualID");
-  programs = 0;
-  capture_stderr_p = get_boolean_resource ("captureStderr", "Boolean");
-  overlay_stderr_p = get_boolean_resource ("overlayStderr", "Boolean");
-  stderr_font = get_string_resource ("font", "Font");
-
-  i = 0;
-  for (j = 0; j < p->screenhacks_count; j++)
-    i += strlen(p->screenhacks[j]) + 2;
-  {
-    char *ss = programs = (char *) malloc(i + 10);
-    *ss = 0;
-    for (j = 0; j < p->screenhacks_count; j++)
-      {
-       strcat(ss, p->screenhacks[j]);
-       ss += strlen(ss);
-       *ss++ = '\n';
-       *ss = 0;
-      }
-  }
-
-  {
-    struct passwd *p = getpwuid (getuid ());
-    char *whoami = (p && p->pw_name && *p->pw_name
-                   ? p->pw_name : "<unknown>");
-    fprintf (out, 
-            "# %s Preferences File\n"
-            "# Written by %s %s for %s on %s.\n"
-            "# http://www.jwz.org/xscreensaver/\n"
-            "\n",
-            progclass, progname, si->version,
-            (whoami ? whoami : "<unknown>"),
-            timestring());
-  }
-
-  for (j = 0; prefs[j]; j++)
-    {
-      char buf[255];
-      const char *pr = prefs[j];
-      enum pref_type { pref_str, pref_int, pref_bool, pref_time
-      } type = pref_str;
-      const char *s = 0;
-      int i = 0;
-      Bool b = False;
-      Time t = 0;
-
-      if (pr && !*pr)
-       {
-         fprintf(out, "\n");
-         continue;
-       }
-
-# undef CHECK
-# define CHECK(X) else if (!strcmp(pr, X))
-      if (!pr || !*pr)         ;
-      CHECK("timeout")         type = pref_time, t = p->timeout;
-      CHECK("cycle")           type = pref_time, t = p->cycle;
-      CHECK("lock")            type = pref_bool, b = p->lock_p;
-# if 0 /* #### not ready yet */
-      CHECK("lockVTs")         type = pref_bool, b = p->lock_vt_p;
-# else
-      CHECK("lockVTs")         continue;  /* don't save */
-# endif
-      CHECK("lockTimeout")     type = pref_time, t = p->lock_timeout;
-      CHECK("passwdTimeout")   type = pref_time, t = p->passwd_timeout;
-      CHECK("visualID")                type = pref_str,  s =    visual_name;
-      CHECK("installColormap") type = pref_bool, b = p->install_cmap_p;
-      CHECK("verbose")         type = pref_bool, b = p->verbose_p;
-      CHECK("timestamp")       type = pref_bool, b = p->timestamp_p;
-      CHECK("splash")          continue;  /* don't save */
-      CHECK("splashDuration")  type = pref_time, t = p->splash_duration;
-      CHECK("helpURL")         type = pref_str,  s = p->help_url;
-      CHECK("loadURL")         type = pref_str,  s = p->load_url_command;
-      CHECK("nice")            type = pref_int,  i = p->nice_inferior;
-      CHECK("fade")            type = pref_bool, b = p->fade_p;
-      CHECK("unfade")          type = pref_bool, b = p->unfade_p;
-      CHECK("fadeSeconds")     type = pref_time, t = p->fade_seconds;
-      CHECK("fadeTicks")       type = pref_int,  i = p->fade_ticks;
-      CHECK("captureStderr")   type = pref_bool, b =    capture_stderr_p;
-      CHECK("captureStdout")   continue;  /* don't save */
-      CHECK("font")            type = pref_str,  s =    stderr_font;
-      CHECK("programs")                type = pref_str,  s =    programs;
-      CHECK("pointerPollTime") type = pref_time, t = p->pointer_timeout;
-      CHECK("windowCreationTimeout")type=pref_time,t= p->notice_events_timeout;
-      CHECK("initialDelay")    type = pref_time, t = p->initial_delay;
-      CHECK("sgiSaverExtension")type = pref_bool, b=p->use_sgi_saver_extension;
-      CHECK("mitSaverExtension")type = pref_bool, b=p->use_mit_saver_extension;
-      CHECK("xidleExtension")  type = pref_bool, b = p->use_xidle_extension;
-      CHECK("overlayStderr")   type = pref_bool, b = overlay_stderr_p;
-      CHECK("overlayTextBackground") continue;  /* don't save */
-      CHECK("overlayTextForeground") continue;  /* don't save */
-      CHECK("bourneShell")     continue;
-      else                     abort();
-# undef CHECK
-
-      switch (type)
-       {
-       case pref_str:
-         break;
-       case pref_int:
-         sprintf(buf, "%d", i);
-         s = buf;
-         break;
-       case pref_bool:
-         s = b ? "True" : "False";
-         break;
-       case pref_time:
-         {
-           unsigned int hour = 0, min = 0, sec = (unsigned int) (t/1000);
-           if (sec >= 60)
-             {
-               min += (sec / 60);
-               sec %= 60;
-             }
-           if (min >= 60)
-             {
-               hour += (min / 60);
-               min %= 60;
-             }
-           sprintf (buf, "%u:%02u:%02u", hour, min, sec);
-           s = buf;
-         }
-         break;
-       default:
-         abort();
-         break;
-       }
-      write_entry (out, pr, s);
-    }
-
-  fprintf(out, "\n");
-
-  if (visual_name) free(visual_name);
-  if (stderr_font) free(stderr_font);
-  if (programs) free(programs);
-
-  if (fclose(out) == 0)
-    {
-      time_t write_date = 0;
-
-      if (stat(tmp_name, &st) == 0)
-       {
-         write_date = st.st_mtime;
-       }
-      else
-       {
-         char *buf = (char *) malloc(1024 + strlen(tmp_name) + strlen(name));
-         sprintf(buf, "%s: couldn't stat %s", blurb(), tmp_name);
-         perror(buf);
-         unlink (tmp_name);
-         free(buf);
-         return -1;
-       }
-
-      if (rename (tmp_name, name) != 0)
-       {
-         char *buf = (char *) malloc(1024 + strlen(tmp_name) + strlen(name));
-         sprintf(buf, "%s: error renaming %s to %s", blurb(), tmp_name, name);
-         perror(buf);
-         unlink (tmp_name);
-         free(buf);
-         return -1;
-       }
-      else
-       {
-         si->init_file_date = write_date;
-       }
-    }
-  else
-    {
-      char *buf = (char *) malloc(1024 + strlen(name));
-      sprintf(buf, "%s: error closing %s", blurb(), name);
-      perror(buf);
-      free(buf);
-      unlink (tmp_name);
-      return -1;
-    }
-
-  return 0;
-}
index 7a3ed6a259ffbf3ca1a6a5a6da6fdae625f8c64f..c87597832039ee11f32fb5f8ca0dfa1312f7b25b 100644 (file)
 #include "xscreensaver.h"
 #include "resources.h"
 
+#ifdef HAVE_SYSLOG
+# include <syslog.h>
+#endif /* HAVE_SYSLOG */
+
 #ifdef _VROOT_H_
 ERROR!  You must not include vroot.h in this file.
 #endif
@@ -48,7 +52,7 @@ vms_passwd_valid_p(char *pw)
 #undef MAX
 #define MAX(a,b) ((a)>(b)?(a):(b))
 
-enum passwd_state { pw_read, pw_ok, pw_fail, pw_cancel, pw_time };
+enum passwd_state { pw_read, pw_ok, pw_null, pw_fail, pw_cancel, pw_time };
 
 struct passwd_dialog_data {
 
@@ -698,6 +702,8 @@ handle_passwd_key (saver_info *si, XKeyEvent *event)
        ;  /* already done? */
       else if (passwd_valid_p (typed_passwd))
        pw->state = pw_ok;
+      else if (typed_passwd[0] == 0)
+       pw->state = pw_null;
       else
        pw->state = pw_fail;
       break;
@@ -726,6 +732,7 @@ handle_passwd_key (saver_info *si, XKeyEvent *event)
 static void
 passwd_event_loop (saver_info *si)
 {
+  saver_preferences *p = &si->prefs;
   char *msg = 0;
   XEvent event;
   passwd_animate_timer ((XtPointer) si, 0);
@@ -744,10 +751,76 @@ passwd_event_loop (saver_info *si)
   switch (si->pw_data->state)
     {
     case pw_ok:   msg = 0; break;
+    case pw_null: msg = ""; break;
     case pw_time: msg = "Timed out!"; break;
     default:      msg = "Sorry!"; break;
     }
 
+  if (si->pw_data->state == pw_fail)
+    si->unlock_failures++;
+
+  if (p->verbose_p)
+    switch (si->pw_data->state)
+      {
+      case pw_ok:
+       fprintf (stderr, "%s: password correct.\n", blurb()); break;
+      case pw_fail:
+       fprintf (stderr, "%s: password incorrect!\n", blurb()); break;
+      case pw_null:
+      case pw_cancel:
+       fprintf (stderr, "%s: password entry cancelled.\n", blurb()); break;
+      case pw_time:
+       fprintf (stderr, "%s: password entry timed out.\n", blurb()); break;
+      default: break;
+      }
+
+#ifdef HAVE_SYSLOG
+  if (si->pw_data->state == pw_fail)
+    {
+      /* If they typed a password (as opposed to just hitting return) and
+        the password was invalid, log it.
+      */
+      struct passwd *pw = getpwuid (getuid ());
+      char *d = DisplayString (si->dpy);
+      char *u = (pw->pw_name ? pw->pw_name : "???");
+      int opt = 0;
+      int fac = 0;
+
+# ifdef LOG_PID
+      opt = LOG_PID;
+# endif
+
+# if defined(LOG_AUTHPRIV)
+      fac = LOG_AUTHPRIV;
+# elif defined(LOG_AUTH)
+      fac = LOG_AUTH;
+# else
+      fac = LOG_DAEMON;
+# endif
+
+      if (!d) d = "";
+      openlog (progname, opt, fac);
+      syslog (LOG_NOTICE, "FAILED LOGIN %d ON DISPLAY \"%s\", FOR \"%s\"",
+             si->unlock_failures, d, u);
+      closelog ();
+    }
+#endif /* HAVE_SYSLOG */
+
+  if (si->pw_data->state == pw_ok && si->unlock_failures != 0)
+    {
+      if (si->unlock_failures == 1)
+       fprintf (real_stderr,
+                "%s: WARNING: 1 failed attempt to unlock the screen.\n",
+                blurb());
+      else
+       fprintf (real_stderr,
+                "%s: WARNING: %d failed attempts to unlock the screen.\n",
+                blurb(), si->unlock_failures);
+      fflush (real_stderr);
+
+      si->unlock_failures = 0;
+    }
+
   if (msg)
     {
       si->pw_data->i_beam = 0;
@@ -765,13 +838,18 @@ passwd_event_loop (saver_info *si)
     }
 }
 
+
 Bool
 unlock_p (saver_info *si)
 {
+  saver_preferences *p = &si->prefs;
   Screen *screen = si->default_screen->screen;
   Colormap cmap = DefaultColormapOfScreen (screen);
   Bool status;
 
+  if (p->verbose_p)
+    fprintf (stderr, "%s: prompting for password.\n", blurb());
+
   if (si->pw_data || si->passwd_dialog)
     destroy_passwd_window (si);
 
diff --git a/driver/prefs.c b/driver/prefs.c
new file mode 100644 (file)
index 0000000..306e694
--- /dev/null
@@ -0,0 +1,1005 @@
+/* dotfile.c --- management of the ~/.xscreensaver file.
+ * xscreensaver, Copyright (c) 1998 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
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation.  No representations are made about the suitability of this
+ * software for any purpose.  It is provided "as is" without express or 
+ * implied warranty.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <stdlib.h>
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xresource.h>
+
+#ifndef VMS
+# include <pwd.h>
+#else /* VMS */
+# include "vms-pwd.h"
+#endif /* VMS */
+
+
+/* This file doesn't need the Xt headers, so stub these types out... */
+#undef XtPointer
+#define XtAppContext void*
+#define XtIntervalId void*
+#define XtPointer    void*
+#define Widget       void*
+
+
+/* Just in case there's something pathological about stat.h... */
+#ifndef  S_IRUSR
+# define S_IRUSR 00400
+#endif
+#ifndef  S_IWUSR
+# define S_IWUSR 00200
+#endif
+#ifndef  S_IXUSR
+# define S_IXUSR 00100
+#endif
+#ifndef  S_IXGRP
+# define S_IXGRP 00010
+#endif
+#ifndef  S_IXOTH
+# define S_IXOTH 00001
+#endif
+
+
+#include "prefs.h"
+#include "resources.h"
+
+
+extern char *progname;
+extern char *progclass;
+extern const char *blurb (void);
+
+
+
+static void get_screenhacks (saver_preferences *p);
+
+
+const char *
+init_file_name (void)
+{
+  static char *file = 0;
+
+  if (!file)
+    {
+      struct passwd *p = getpwuid (getuid ());
+
+      if (!p || !p->pw_name || !*p->pw_name)
+       {
+         fprintf (stderr, "%s: couldn't get user info of uid %d\n",
+                  blurb(), getuid ());
+         file = "";
+       }
+      else if (!p->pw_dir || !*p->pw_dir)
+       {
+         fprintf (stderr, "%s: couldn't get home directory of \"%s\"\n",
+                  blurb(), (p->pw_name ? p->pw_name : "???"));
+         file = "";
+       }
+      else
+       {
+         const char *home = p->pw_dir;
+         const char *name = ".xscreensaver";
+         file = (char *) malloc(strlen(home) + strlen(name) + 2);
+         strcpy(file, home);
+         if (!*home || home[strlen(home)-1] != '/')
+           strcat(file, "/");
+         strcat(file, name);
+       }
+    }
+
+  if (file && *file)
+    return file;
+  else
+    return 0;
+}
+
+
+static const char *
+init_file_tmp_name (void)
+{
+  static char *file = 0;
+  if (!file)
+    {
+      const char *name = init_file_name();
+      const char *suffix = ".tmp";
+      if (!name || !*name)
+       file = "";
+      else
+       {
+         file = (char *) malloc(strlen(name) + strlen(suffix) + 2);
+         strcpy(file, name);
+         strcat(file, suffix);
+       }
+    }
+
+  if (file && *file)
+    return file;
+  else
+    return 0;
+}
+
+
+static const char * const prefs[] = {
+  "timeout",
+  "cycle",
+  "lock",
+  "lockVTs",
+  "lockTimeout",
+  "passwdTimeout",
+  "visualID",
+  "installColormap",
+  "verbose",
+  "timestamp",
+  "splash",                    /* not saved -- same as "splashDuration: 0" */
+  "splashDuration",
+  "demoCommand",
+  "prefsCommand",
+  "helpURL",
+  "loadURL",
+  "nice",
+  "fade",
+  "unfade",
+  "fadeSeconds",
+  "fadeTicks",
+  "captureStderr",
+  "captureStdout",             /* not saved -- obsolete */
+  "font",
+  "",
+  "programs",
+  "",
+  "pointerPollTime",
+  "windowCreationTimeout",
+  "initialDelay",
+  "sgiSaverExtension",
+  "mitSaverExtension",
+  "xidleExtension",
+  "overlayStderr",
+  "overlayTextBackground",     /* not saved -- X resources only */
+  "overlayTextForeground",     /* not saved -- X resources only */
+  "bourneShell",               /* not saved -- X resources only */
+  0
+};
+
+static char *
+strip (char *s)
+{
+  char *s2;
+  while (*s == '\t' || *s == ' ' || *s == '\r' || *s == '\n')
+    s++;
+  for (s2 = s; *s2; s2++)
+    ;
+  for (s2--; s2 >= s; s2--) 
+    if (*s2 == '\t' || *s2 == ' ' || *s2 == '\r' || *s2 =='\n') 
+      *s2 = 0;
+    else
+      break;
+  return s;
+}
+
+\f
+/* Reading
+ */
+
+static int
+handle_entry (XrmDatabase *db, const char *key, const char *value,
+             const char *filename, int line)
+{
+  int i;
+  for (i = 0; prefs[i]; i++)
+    if (*prefs[i] && !strcasecmp(key, prefs[i]))
+      {
+       char *val = strdup(value);
+       char *spec = (char *) malloc(strlen(progclass) + strlen(prefs[i]) +10);
+       strcpy(spec, progclass);
+       strcat(spec, ".");
+       strcat(spec, prefs[i]);
+
+       XrmPutStringResource (db, spec, val);
+
+       free(spec);
+       free(val);
+       return 0;
+      }
+
+  fprintf(stderr, "%s: %s:%d: unknown option \"%s\"\n",
+         blurb(), filename, line, key);
+  return 1;
+}
+
+
+static int
+parse_init_file (saver_preferences *p)
+{
+  time_t write_date = 0;
+  const char *name = init_file_name();
+  int line = 0;
+  struct stat st;
+  FILE *in;
+  int buf_size = 1024;
+  char *buf;
+
+  if (!name) return 0;
+
+  if (stat(name, &st) != 0)
+    {
+      p->init_file_date = 0;
+      return 0;
+    }
+
+  in = fopen(name, "r");
+  if (!in)
+    {
+      char *buf = (char *) malloc(1024 + strlen(name));
+      sprintf(buf, "%s: error reading \"%s\"", blurb(), name);
+      perror(buf);
+      free(buf);
+      return -1;
+    }
+
+  if (fstat (fileno(in), &st) == 0)
+    {
+      write_date = st.st_mtime;
+    }
+  else
+    {
+      char *buf = (char *) malloc(1024 + strlen(name));
+      sprintf(buf, "%s: couldn't re-stat \"%s\"", blurb(), name);
+      perror(buf);
+      free(buf);
+      return -1;
+    }
+
+  buf = (char *) malloc(buf_size);
+
+  while (fgets (buf, buf_size-1, in))
+    {
+      char *key, *value;
+      int L = strlen(buf);
+
+      line++;
+      while (L > 2 &&
+            (buf[L-1] != '\n' ||       /* whole line didn't fit in buffer */
+             buf[L-2] == '\\'))        /* or line ended with backslash */
+       {
+         if (buf[L-2] == '\\')         /* backslash-newline gets swallowed */
+           {
+             buf[L-2] = 0;
+             L -= 2;
+           }
+         buf_size += 1024;
+         buf = (char *) realloc(buf, buf_size);
+         if (!buf) exit(1);
+
+         line++;
+         if (!fgets (buf + L, buf_size-L-1, in))
+           break;
+         L = strlen(buf);
+       }
+
+      /* Now handle other backslash escapes. */
+      {
+       int i, j;
+       for (i = 0; buf[i]; i++)
+         if (buf[i] == '\\')
+           {
+             switch (buf[i+1])
+               {
+               case 'n': buf[i] = '\n'; break;
+               case 'r': buf[i] = '\r'; break;
+               case 't': buf[i] = '\t'; break;
+               default:  buf[i] = buf[i+1]; break;
+               }
+             for (j = i+2; buf[j]; j++)
+               buf[j-1] = buf[j];
+             buf[j-1] = 0;
+           }
+      }
+
+      key = strip(buf);
+
+      if (*key == '#' || *key == '!' || *key == ';' ||
+         *key == '\n' || *key == 0)
+       continue;
+
+      value = strchr (key, ':');
+      if (!value)
+       {
+         fprintf(stderr, "%s: %s:%d: unparsable line: %s\n", blurb(),
+                 name, line, key);
+         continue;
+       }
+      else
+       {
+         *value++ = 0;
+         value = strip(value);
+       }
+
+      if (!p->db) abort();
+      handle_entry (&p->db, key, value, name, line);
+    }
+  free(buf);
+
+  p->init_file_date = write_date;
+  return 0;
+}
+
+
+Bool
+init_file_changed_p (saver_preferences *p)
+{
+  const char *name = init_file_name();
+  struct stat st;
+
+  if (!name) return False;
+
+  if (stat(name, &st) != 0)
+    return False;
+
+  if (p->init_file_date == st.st_mtime)
+    return False;
+
+  return True;
+}
+
+\f
+/* Writing
+ */
+
+static int
+tab_to (FILE *out, int from, int to)
+{
+  int tab_width = 8;
+  int to_mod = (to / tab_width) * tab_width;
+  while (from < to_mod)
+    {
+      fprintf(out, "\t");
+      from = (((from / tab_width) + 1) * tab_width);
+    }
+  while (from < to)
+    {
+      fprintf(out, " ");
+      from++;
+    }
+  return from;
+}
+
+static void
+write_entry (FILE *out, const char *key, const char *value)
+{
+  char *v = strdup(value ? value : "");
+  char *v2 = v;
+  char *nl = 0;
+  int col;
+  Bool do_visual_kludge = (!strcmp(key, "programs"));
+  Bool do_wrap = do_visual_kludge;
+  int tab = (do_visual_kludge ? 16 : 23);
+  int tab2 = 3;
+  Bool first = True;
+
+  fprintf(out, "%s:", key);
+  col = strlen(key) + 1;
+
+  while (1)
+    {
+      char *s;
+      Bool disabled_p = False;
+
+      v2 = strip(v2);
+      nl = strchr(v2, '\n');
+      if (nl)
+       *nl = 0;
+
+      if (do_visual_kludge && *v2 == '-')
+       {
+         disabled_p = True;
+         v2++;
+         v2 = strip(v2);
+       }
+
+      if (first && disabled_p)
+       first = False;
+
+      if (first)
+       first = False;
+      else
+       {
+         col = tab_to(out, col, 75);
+         fprintf(out, " \\n\\\n");
+         col = 0;
+       }
+
+      if (disabled_p)
+       {
+         fprintf(out, "-");
+         col++;
+       }
+
+      s = (do_visual_kludge ? strpbrk(v2, " \t\n:") : 0);
+      if (s && *s == ':')
+       col = tab_to (out, col, tab2);
+      else
+       col = tab_to (out, col, tab);
+
+      if (do_wrap &&
+         strlen(v2) + col > 75)
+       {
+         int L = strlen(v2);
+         int start = 0;
+         int end = start;
+         while (start < L)
+           {
+             while (v2[end] == ' ' || v2[end] == '\t')
+               end++;
+             while (v2[end] != ' ' && v2[end] != '\t' &&
+                    v2[end] != '\n' && v2[end] != 0)
+               end++;
+             if (col + (end - start) >= 74)
+               {
+                 col = tab_to (out, col, 75);
+                 fprintf(out, "   \\\n");
+                 col = tab_to (out, 0, tab + 2);
+                 while (v2[start] == ' ' || v2[start] == '\t')
+                   start++;
+               }
+
+             while (start < end)
+               {
+                 fputc(v2[start++], out);
+                 col++;
+               }
+           }
+       }
+      else
+       {
+         fprintf (out, "%s", v2);
+         col += strlen(v2);
+       }
+
+      if (nl)
+       v2 = nl + 1;
+      else
+       break;
+    }
+
+  fprintf(out, "\n");
+  free(v);
+}
+
+void
+write_init_file (saver_preferences *p, const char *version_string)
+{
+  const char *name = init_file_name();
+  const char *tmp_name = init_file_tmp_name();
+  struct stat st;
+  int i, j;
+
+  /* Kludge, since these aren't in the saver_preferences struct as strings...
+   */
+  char *visual_name;
+  char *programs;
+  Bool capture_stderr_p;
+  Bool overlay_stderr_p;
+  char *stderr_font;
+  FILE *out;
+
+  if (!name) return;
+
+  if (p->verbose_p)
+    fprintf (stderr, "%s: writing \"%s\".\n", blurb(), name);
+
+  unlink (tmp_name);
+  out = fopen(tmp_name, "w");
+  if (!out)
+    {
+      char *buf = (char *) malloc(1024 + strlen(name));
+      sprintf(buf, "%s: error writing \"%s\"", blurb(), name);
+      perror(buf);
+      free(buf);
+      return;
+    }
+
+  /* Give the new .xscreensaver file the same permissions as the old one;
+     except ensure that it is readable and writable by owner, and not
+     executable.
+   */
+  if (stat(name, &st) == 0)
+    {
+      mode_t mode = st.st_mode;
+      mode |= S_IRUSR | S_IWUSR;
+      mode &= ~(S_IXUSR | S_IXGRP | S_IXOTH);
+      if (fchmod (fileno(out), mode) != 0)
+       {
+         char *buf = (char *) malloc(1024 + strlen(name));
+         sprintf (buf, "%s: error fchmodding \"%s\" to 0%o", blurb(),
+                  tmp_name, (unsigned int) mode);
+         perror(buf);
+         free(buf);
+         return;
+       }
+    }
+
+  /* Kludge, since these aren't in the saver_preferences struct... */
+  visual_name = get_string_resource ("visualID", "VisualID");
+  programs = 0;
+  capture_stderr_p = get_boolean_resource ("captureStderr", "Boolean");
+  overlay_stderr_p = get_boolean_resource ("overlayStderr", "Boolean");
+  stderr_font = get_string_resource ("font", "Font");
+
+  i = 0;
+  for (j = 0; j < p->screenhacks_count; j++)
+    i += strlen(p->screenhacks[j]) + 2;
+  {
+    char *ss = programs = (char *) malloc(i + 10);
+    *ss = 0;
+    for (j = 0; j < p->screenhacks_count; j++)
+      {
+       strcat(ss, p->screenhacks[j]);
+       ss += strlen(ss);
+       *ss++ = '\n';
+       *ss = 0;
+      }
+  }
+
+  {
+    struct passwd *pw = getpwuid (getuid ());
+    char *whoami = (pw && pw->pw_name && *pw->pw_name
+                   ? pw->pw_name
+                   : "<unknown>");
+    time_t now = time ((time_t *) 0);
+    char *timestr = (char *) ctime (&now);
+    char *nl = (char *) strchr (timestr, '\n');
+    if (nl) *nl = 0;
+    fprintf (out,
+            "# %s Preferences File\n"
+            "# Written by %s %s for %s on %s.\n"
+            "# http://www.jwz.org/xscreensaver/\n"
+            "\n",
+            progclass, progname, version_string, whoami, timestr);
+  }
+
+  for (j = 0; prefs[j]; j++)
+    {
+      char buf[255];
+      const char *pr = prefs[j];
+      enum pref_type { pref_str, pref_int, pref_bool, pref_time
+      } type = pref_str;
+      const char *s = 0;
+      int i = 0;
+      Bool b = False;
+      Time t = 0;
+
+      if (pr && !*pr)
+       {
+         fprintf(out, "\n");
+         continue;
+       }
+
+# undef CHECK
+# define CHECK(X) else if (!strcmp(pr, X))
+      if (!pr || !*pr)         ;
+      CHECK("timeout")         type = pref_time, t = p->timeout;
+      CHECK("cycle")           type = pref_time, t = p->cycle;
+      CHECK("lock")            type = pref_bool, b = p->lock_p;
+# if 0 /* #### not ready yet */
+      CHECK("lockVTs")         type = pref_bool, b = p->lock_vt_p;
+# else
+      CHECK("lockVTs")         continue;  /* don't save */
+# endif
+      CHECK("lockTimeout")     type = pref_time, t = p->lock_timeout;
+      CHECK("passwdTimeout")   type = pref_time, t = p->passwd_timeout;
+      CHECK("visualID")                type = pref_str,  s =    visual_name;
+      CHECK("installColormap") type = pref_bool, b = p->install_cmap_p;
+      CHECK("verbose")         type = pref_bool, b = p->verbose_p;
+      CHECK("timestamp")       type = pref_bool, b = p->timestamp_p;
+      CHECK("splash")          continue;  /* don't save */
+      CHECK("splashDuration")  type = pref_time, t = p->splash_duration;
+      CHECK("demoCommand")     type = pref_str,  s = p->demo_command;
+      CHECK("prefsCommand")    type = pref_str,  s = p->prefs_command;
+      CHECK("helpURL")         type = pref_str,  s = p->help_url;
+      CHECK("loadURL")         type = pref_str,  s = p->load_url_command;
+      CHECK("nice")            type = pref_int,  i = p->nice_inferior;
+      CHECK("fade")            type = pref_bool, b = p->fade_p;
+      CHECK("unfade")          type = pref_bool, b = p->unfade_p;
+      CHECK("fadeSeconds")     type = pref_time, t = p->fade_seconds;
+      CHECK("fadeTicks")       type = pref_int,  i = p->fade_ticks;
+      CHECK("captureStderr")   type = pref_bool, b =    capture_stderr_p;
+      CHECK("captureStdout")   continue;  /* don't save */
+      CHECK("font")            type = pref_str,  s =    stderr_font;
+      CHECK("programs")                type = pref_str,  s =    programs;
+      CHECK("pointerPollTime") type = pref_time, t = p->pointer_timeout;
+      CHECK("windowCreationTimeout")type=pref_time,t= p->notice_events_timeout;
+      CHECK("initialDelay")    type = pref_time, t = p->initial_delay;
+      CHECK("sgiSaverExtension")type = pref_bool, b=p->use_sgi_saver_extension;
+      CHECK("mitSaverExtension")type = pref_bool, b=p->use_mit_saver_extension;
+      CHECK("xidleExtension")  type = pref_bool, b = p->use_xidle_extension;
+      CHECK("overlayStderr")   type = pref_bool, b = overlay_stderr_p;
+      CHECK("overlayTextBackground") continue;  /* don't save */
+      CHECK("overlayTextForeground") continue;  /* don't save */
+      CHECK("bourneShell")     continue;
+      else                     abort();
+# undef CHECK
+
+      switch (type)
+       {
+       case pref_str:
+         break;
+       case pref_int:
+         sprintf(buf, "%d", i);
+         s = buf;
+         break;
+       case pref_bool:
+         s = b ? "True" : "False";
+         break;
+       case pref_time:
+         {
+           unsigned int hour = 0, min = 0, sec = (unsigned int) (t/1000);
+           if (sec >= 60)
+             {
+               min += (sec / 60);
+               sec %= 60;
+             }
+           if (min >= 60)
+             {
+               hour += (min / 60);
+               min %= 60;
+             }
+           sprintf (buf, "%u:%02u:%02u", hour, min, sec);
+           s = buf;
+         }
+         break;
+       default:
+         abort();
+         break;
+       }
+      write_entry (out, pr, s);
+    }
+
+  fprintf(out, "\n");
+
+  if (visual_name) free(visual_name);
+  if (stderr_font) free(stderr_font);
+  if (programs) free(programs);
+
+  if (fclose(out) == 0)
+    {
+      time_t write_date = 0;
+
+      if (stat(tmp_name, &st) == 0)
+       {
+         write_date = st.st_mtime;
+       }
+      else
+       {
+         char *buf = (char *) malloc(1024 + strlen(tmp_name) + strlen(name));
+         sprintf(buf, "%s: couldn't stat \"%s\"", blurb(), tmp_name);
+         perror(buf);
+         unlink (tmp_name);
+         free(buf);
+         return;
+       }
+
+      if (rename (tmp_name, name) != 0)
+       {
+         char *buf = (char *) malloc(1024 + strlen(tmp_name) + strlen(name));
+         sprintf(buf, "%s: error renaming \"%s\" to \"%s\"",
+                 blurb(), tmp_name, name);
+         perror(buf);
+         unlink (tmp_name);
+         free(buf);
+         return;
+       }
+      else
+       {
+         p->init_file_date = write_date;
+
+         /* Since the .xscreensaver file is used for IPC, let's try and make
+            sure that the bits actually land on the disk right away. */
+         sync ();
+       }
+    }
+  else
+    {
+      char *buf = (char *) malloc(1024 + strlen(name));
+      sprintf(buf, "%s: error closing \"%s\"", blurb(), name);
+      perror(buf);
+      free(buf);
+      unlink (tmp_name);
+      return;
+    }
+}
+
+\f
+/* Parsing the resource database
+ */
+
+
+/* Populate `saver_preferences' with the contents of the resource database.
+   Note that this may be called multiple times -- it is re-run each time
+   the ~/.xscreensaver file is reloaded.
+
+   This function can be very noisy, since it issues resource syntax errors
+   and so on.
+ */
+void
+load_init_file (saver_preferences *p)
+{
+  static Bool first_time = True;
+  
+  if (parse_init_file (p) != 0)                /* file might have gone away */
+    if (!first_time) return;
+
+  first_time = False;
+
+  p->xsync_p       = get_boolean_resource ("synchronous", "Synchronous");
+  p->verbose_p     = get_boolean_resource ("verbose", "Boolean");
+  p->timestamp_p    = get_boolean_resource ("timestamp", "Boolean");
+  p->lock_p        = get_boolean_resource ("lock", "Boolean");
+  p->lock_vt_p     = get_boolean_resource ("lockVTs", "Boolean");
+  p->fade_p        = get_boolean_resource ("fade", "Boolean");
+  p->unfade_p      = get_boolean_resource ("unfade", "Boolean");
+  p->fade_seconds   = 1000 * get_seconds_resource ("fadeSeconds", "Time");
+  p->fade_ticks            = get_integer_resource ("fadeTicks", "Integer");
+  p->install_cmap_p = get_boolean_resource ("installColormap", "Boolean");
+  p->nice_inferior  = get_integer_resource ("nice", "Nice");
+
+  p->initial_delay   = 1000 * get_seconds_resource ("initialDelay", "Time");
+  p->splash_duration = 1000 * get_seconds_resource ("splashDuration", "Time");
+  p->timeout         = 1000 * get_minutes_resource ("timeout", "Time");
+  p->lock_timeout    = 1000 * get_minutes_resource ("lockTimeout", "Time");
+  p->cycle           = 1000 * get_minutes_resource ("cycle", "Time");
+  p->passwd_timeout  = 1000 * get_seconds_resource ("passwdTimeout", "Time");
+  p->pointer_timeout = 1000 * get_seconds_resource ("pointerPollTime", "Time");
+  p->notice_events_timeout = 1000*get_seconds_resource("windowCreationTimeout",
+                                                      "Time");
+  p->shell = get_string_resource ("bourneShell", "BourneShell");
+
+  p->demo_command = get_string_resource("demoCommand", "URL");
+  p->prefs_command = get_string_resource("prefsCommand", "URL");
+  p->help_url = get_string_resource("helpURL", "URL");
+  p->load_url_command = get_string_resource("loadURL", "LoadURL");
+
+  {
+    char *s;
+    if ((s = get_string_resource ("splash", "Boolean")))
+      if (!get_boolean_resource("splash", "Boolean"))
+       p->splash_duration = 0;
+    if (s) free (s);
+  }
+
+  p->use_xidle_extension = get_boolean_resource ("xidleExtension","Boolean");
+  p->use_mit_saver_extension = get_boolean_resource ("mitSaverExtension",
+                                                    "Boolean");
+  p->use_sgi_saver_extension = get_boolean_resource ("sgiSaverExtension",
+                                                    "Boolean");
+
+  /* Throttle the various timeouts to reasonable values.
+   */
+  if (p->passwd_timeout <= 0) p->passwd_timeout = 30000;        /* 30 secs */
+  if (p->timeout < 10000) p->timeout = 10000;                   /* 10 secs */
+  if (p->cycle < 0) p->cycle = 0;
+  if (p->cycle != 0 && p->cycle < 2000) p->cycle = 2000;        /*  2 secs */
+  if (p->pointer_timeout <= 0) p->pointer_timeout = 5000;       /*  5 secs */
+  if (p->notice_events_timeout <= 0)
+    p->notice_events_timeout = 10000;                           /* 10 secs */
+  if (p->fade_seconds <= 0 || p->fade_ticks <= 0)
+    p->fade_p = False;
+  if (! p->fade_p) p->unfade_p = False;
+
+  if (p->verbose_p && !p->fading_possible_p && (p->fade_p || p->unfade_p))
+    {
+      fprintf (stderr, "%s: there are no PseudoColor or GrayScale visuals.\n",
+              blurb());
+      fprintf (stderr, "%s: ignoring the request for fading/unfading.\n",
+              blurb());
+    }
+
+  p->watchdog_timeout = p->cycle;
+  if (p->watchdog_timeout < 30000) p->watchdog_timeout = 30000;          /* 30 secs */
+  if (p->watchdog_timeout > 3600000) p->watchdog_timeout = 3600000; /*  1 hr */
+
+  get_screenhacks (p);
+
+  if (p->debug_p)
+    {
+      p->xsync_p = True;
+      p->verbose_p = True;
+      p->timestamp_p = True;
+      p->initial_delay = 0;
+    }
+}
+
+\f
+/* Parsing the programs resource.
+ */
+
+static char *
+reformat_hack (const char *hack)
+{
+  int i;
+  const char *in = hack;
+  int indent = 15;
+  char *h2 = (char *) malloc(strlen(in) + indent + 2);
+  char *out = h2;
+  Bool disabled_p = False;
+
+  while (isspace(*in)) in++;           /* skip whitespace */
+
+  if (*in == '-')                      /* Handle a leading "-". */
+    {
+      in++;
+      hack = in;
+      *out++ = '-';
+      *out++ = ' ';
+      disabled_p = True;
+      while (isspace(*in)) in++;
+    }
+  else
+    {
+      *out++ = ' ';
+      *out++ = ' ';
+    }
+
+  while (*in && !isspace(*in) && *in != ':')
+    *out++ = *in++;                    /* snarf first token */
+  while (isspace(*in)) in++;           /* skip whitespace */
+
+  if (*in == ':')
+    *out++ = *in++;                    /* copy colon */
+  else
+    {
+      in = hack;
+      out = h2 + 2;                    /* reset to beginning */
+    }
+
+  *out = 0;
+
+  while (isspace(*in)) in++;           /* skip whitespace */
+  for (i = strlen(h2); i < indent; i++)        /* indent */
+    *out++ = ' ';
+
+  /* copy the rest of the line. */
+  while (*in)
+    {
+      /* shrink all whitespace to one space, for the benefit of the "demo"
+        mode display.  We only do this when we can easily tell that the
+        whitespace is not significant (no shell metachars).
+       */
+      switch (*in)
+       {
+       case '\'': case '"': case '`': case '\\':
+         {
+           /* Metachars are scary.  Copy the rest of the line unchanged. */
+           while (*in)
+             *out++ = *in++;
+         }
+         break;
+       case ' ': case '\t':
+         {
+           while (*in == ' ' || *in == '\t')
+             in++;
+           *out++ = ' ';
+         }
+         break;
+       default:
+         *out++ = *in++;
+         break;
+       }
+    }
+  *out = 0;
+
+  /* strip trailing whitespace. */
+  out = out-1;
+  while (out > h2 && (*out == ' ' || *out == '\t' || *out == '\n'))
+    *out-- = 0;
+
+  return h2;
+}
+
+
+static void
+get_screenhacks (saver_preferences *p)
+{
+  int i = 0;
+  int start = 0;
+  int end = 0;
+  int size;
+  char *d;
+
+  d = get_string_resource ("monoPrograms", "MonoPrograms");
+  if (d && !*d) { free(d); d = 0; }
+  if (!d)
+    d = get_string_resource ("colorPrograms", "ColorPrograms");
+  if (d && !*d) { free(d); d = 0; }
+
+  if (d)
+    {
+      fprintf (stderr,
+       "%s: the `monoPrograms' and `colorPrograms' resources are obsolete;\n\
+       see the manual for details.\n", blurb());
+      free(d);
+    }
+
+  d = get_string_resource ("programs", "Programs");
+
+  if (p->screenhacks)
+    {
+      for (i = 0; i < p->screenhacks_count; i++)
+       if (p->screenhacks[i])
+         free (p->screenhacks[i]);
+      free(p->screenhacks);
+      p->screenhacks = 0;
+    }
+
+  if (!d || !*d)
+    {
+      p->screenhacks_count = 0;
+      p->screenhacks = 0;
+      return;
+    }
+
+  size = strlen (d);
+
+
+  /* Count up the number of newlines (which will be equal to or larger than
+     the number of hacks.)
+   */
+  i = 0;
+  for (i = 0; d[i]; i++)
+    if (d[i] == '\n')
+      i++;
+  i++;
+
+  p->screenhacks = (char **) calloc (sizeof (char *), i+1);
+
+  /* Iterate over the lines in `d' (the string with newlines)
+     and make new strings to stuff into the `screenhacks' array.
+   */
+  p->screenhacks_count = 0;
+  while (start < size)
+    {
+      /* skip forward over whitespace. */
+      while (d[start] == ' ' || d[start] == '\t' || d[start] == '\n')
+       start++;
+
+      /* skip forward to newline or end of string. */
+      end = start;
+      while (d[end] != 0 && d[end] != '\n')
+       end++;
+
+      /* null terminate. */
+      d[end] = 0;
+
+      p->screenhacks[p->screenhacks_count++] = reformat_hack (d + start);
+      if (p->screenhacks_count >= i)
+       abort();
+
+      start = end+1;
+    }
+
+  if (p->screenhacks_count == 0)
+    {
+      free (p->screenhacks);
+      p->screenhacks = 0;
+    }
+}
diff --git a/driver/prefs.h b/driver/prefs.h
new file mode 100644 (file)
index 0000000..cf77f8b
--- /dev/null
@@ -0,0 +1,86 @@
+/* xscreensaver, Copyright (c) 1993-1998 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
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation.  No representations are made about the suitability of this
+ * software for any purpose.  It is provided "as is" without express or 
+ * implied warranty.
+ */
+
+#ifndef __XSCREENSAVER_PREFS_H__
+#define __XSCREENSAVER_PREFS_H__
+
+typedef struct saver_preferences saver_preferences;
+
+
+/* This structure holds all the user-specified parameters, read from the
+   command line, the resource database, or entered through a dialog box.
+ */
+struct saver_preferences {
+
+  XrmDatabase db;              /* The resource database into which the
+                                  init file is merged, and out of which the
+                                  preferences are parsed. */
+
+  time_t init_file_date;       /* The date (from stat()) of the .xscreensaver
+                                  file the last time this process read or
+                                  wrote it. */
+
+  Bool verbose_p;              /* whether to print out lots of status info */
+  Bool timestamp_p;            /* whether to mark messages with a timestamp */
+  Bool debug_p;                        /* pay no mind to the man behind the curtain */
+  Bool xsync_p;                        /* whether XSynchronize has been called */
+
+  Bool lock_p;                 /* whether to lock as well as save */
+  Bool lock_vt_p;              /* whether to lock VTs too, if possible */
+
+  Bool fade_p;                 /* whether to fade to black, if possible */
+  Bool unfade_p;               /* whether to fade from black, if possible */
+  int fade_seconds;            /* how long that should take */
+  int fade_ticks;              /* how many ticks should be used */
+  Bool fading_possible_p;      /* Whether fading to/from black is possible.
+                                  (This isn't strictly a preference, as it
+                                  can only be known by querying the display;
+                                  the caller of the prefs code may fill this
+                                  in if it knows/cares, and warnings will be
+                                  issued.) */
+
+  Bool install_cmap_p;         /* whether we should use our own colormap
+                                  when using the screen's default visual. */
+
+  char **screenhacks;          /* the programs to run */
+  int screenhacks_count;
+
+  int nice_inferior;           /* nice value for subprocs */
+
+  Time initial_delay;          /* how long to sleep after launch */
+  Time splash_duration;                /* how long the splash screen stays up */
+  Time timeout;                        /* how much idle time before activation */
+  Time lock_timeout;           /* how long after activation locking starts */
+  Time cycle;                  /* how long each hack should run */
+  Time passwd_timeout;         /* how much time before pw dialog goes down */
+  Time pointer_timeout;                /* how often to check mouse position */
+  Time notice_events_timeout;  /* how long after window creation to select */
+  Time watchdog_timeout;       /* how often to re-raise and re-blank screen */
+
+  Bool use_xidle_extension;    /* which extension to use, if possible */
+  Bool use_mit_saver_extension;
+  Bool use_sgi_saver_extension;
+
+  char *shell;                 /* where to find /bin/sh */
+
+  char *demo_command;          /* How to enter demo mode. */
+  char *prefs_command;         /* How to edit preferences. */
+  char *help_url;              /* Where the help document resides. */
+  char *load_url_command;      /* How one loads URLs. */
+};
+
+
+extern void load_init_file (saver_preferences *p);
+extern Bool init_file_changed_p (saver_preferences *p);
+extern void write_init_file (saver_preferences *p, const char *version_string);
+const char *init_file_name (void);
+
+#endif /* __XSCREENSAVER_PREFS_H__ */
diff --git a/driver/remote.c b/driver/remote.c
new file mode 100644 (file)
index 0000000..31d4580
--- /dev/null
@@ -0,0 +1,441 @@
+/* xscreensaver-command, Copyright (c) 1991-1998
+ *  by 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
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation.  No representations are made about the suitability of this
+ * software for any purpose.  It is provided "as is" without express or 
+ * implied warranty.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/select.h>
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#include <X11/Xproto.h>                /* for CARD32 */
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>         /* for XGetClassHint() */
+#include <X11/Xos.h>
+
+#include "remote.h"
+
+#ifdef _VROOT_H_
+ERROR! you must not include vroot.h in this file
+#endif
+
+extern char *progname;
+extern Atom XA_SCREENSAVER, XA_SCREENSAVER_VERSION, XA_SCREENSAVER_RESPONSE;
+extern Atom XA_SCREENSAVER_ID, XA_SCREENSAVER_TIME;
+extern Atom XA_VROOT, XA_SELECT, XA_DEMO;
+
+
+static XErrorHandler old_handler = 0;
+static Bool got_badwindow = False;
+static int
+BadWindow_ehandler (Display *dpy, XErrorEvent *error)
+{
+  /* When we notice a window being created, we spawn a timer that waits
+     30 seconds or so, and then selects events on that window.  This error
+     handler is used so that we can cope with the fact that the window
+     may have been destroyed <30 seconds after it was created.
+   */
+  if (error->error_code == BadWindow)
+    {
+      got_badwindow = True;
+      return 0;
+    }
+  else
+    {
+      fprintf (stderr, "%s: ", progname);
+      return (*old_handler) (dpy, error);
+    }
+}
+
+
+
+static Window
+find_screensaver_window (Display *dpy, char **version)
+{
+  int i;
+  Window root = RootWindowOfScreen (DefaultScreenOfDisplay (dpy));
+  Window root2, parent, *kids;
+  unsigned int nkids;
+
+  if (version) *version = 0;
+
+  if (! XQueryTree (dpy, root, &root2, &parent, &kids, &nkids))
+    abort ();
+  if (root != root2)
+    abort ();
+  if (parent)
+    abort ();
+  if (! (kids && nkids))
+    abort ();
+  for (i = 0; i < nkids; i++)
+    {
+      Atom type;
+      int format;
+      unsigned long nitems, bytesafter;
+      char *v;
+
+      if (XGetWindowProperty (dpy, kids[i],
+                             XA_SCREENSAVER_VERSION,
+                             0, 200, False, XA_STRING,
+                             &type, &format, &nitems, &bytesafter,
+                             (unsigned char **) &v)
+         == Success
+         && type != None)
+       {
+         if (version)
+           *version = v;
+         return kids[i];
+       }
+    }
+  fprintf (stderr, "%s: no screensaver is running on display %s\n", progname,
+          DisplayString (dpy));
+  return 0;
+}
+
+
+static int
+send_xscreensaver_command (Display *dpy, Atom command, long arg,
+                          Window *window_ret)
+{
+  char *v = 0;
+  Window window = find_screensaver_window (dpy, &v);
+  XWindowAttributes xgwa;
+
+  if (window_ret)
+    *window_ret = window;
+
+  if (!window)
+    return -1;
+
+  /* Select for property change events, so that we can read the response. */
+  XGetWindowAttributes (dpy, window, &xgwa);
+  XSelectInput (dpy, window, xgwa.your_event_mask | PropertyChangeMask);
+
+  if (command == XA_SCREENSAVER_TIME ||
+      command == XA_SCREENSAVER_VERSION)
+    {
+      XClassHint hint;
+      memset (&hint, 0, sizeof(hint));
+      if (!v || !*v)
+       {
+         fprintf (stderr, "%s: version property not set on window 0x%x?\n",
+                  progname, (unsigned int) window);
+         return -1;
+       }
+
+      XGetClassHint(dpy, window, &hint);
+      if (!hint.res_class)
+       {
+         fprintf (stderr, "%s: class hints not set on window 0x%x?\n",
+                  progname, (unsigned int) window);
+         return -1;
+       }
+
+      fprintf (stdout, "%s %s", hint.res_class, v);
+
+      if (command != XA_SCREENSAVER_TIME)
+       {
+         fprintf (stdout, "\n");
+       }
+      else
+       {
+         Atom type;
+         int format;
+         unsigned long nitems, bytesafter;
+         unsigned char *data = 0;
+         Bool active_p = False;
+
+         if (XGetWindowProperty (dpy, window, XA_VROOT,
+                                 0, 0, False, XA_WINDOW,
+                                 &type, &format, &nitems, &bytesafter,
+                                 &data)
+             == Success
+             && type != None)
+           active_p = True;
+
+         if (data) free (data);
+         data = 0;
+
+         if (XGetWindowProperty (dpy, window,
+                                 XA_SCREENSAVER_TIME,
+                                 0, 1, False, XA_INTEGER,
+                                 &type, &format, &nitems, &bytesafter,
+                                 &data)
+             == Success
+             && type == XA_INTEGER
+             && data)
+           {
+             CARD32 time32 = *((CARD32 *)data);
+             time_t tt = (time_t) time32;
+
+             if (active_p)
+               fprintf (stdout, ": screen blanked since ");
+             else
+               /* suggestions for a better way to phrase this are welcome. */
+               fprintf (stdout, ": screen non-blanked since ");
+             fprintf (stdout, "%s", ctime(&tt));
+             if (data) free (data);
+           }
+         else
+           {
+             if (data) free (data);
+             fprintf (stdout, "\n");
+             fflush (stdout);
+             fprintf (stderr, "%s: no time on window 0x%x (%s %s).\n",
+                      progname, (unsigned int) window,
+                      hint.res_class, (v ? v : "???"));
+             return -1;
+           }
+       }
+
+      /* No need to read a response for these commands. */
+      return 1;
+    }
+  else
+    {
+      XEvent event;
+      long arg1 = arg;
+      long arg2 = 0;
+
+      if (arg < 0)
+       abort();
+      else if (arg == 0 && command == XA_SELECT)
+       abort();
+      else if (arg != 0 && command == XA_DEMO)
+       {
+         arg1 = 300;   /* version number of the XA_DEMO protocol, */
+         arg2 = arg;   /* since it didn't use to take an argument. */
+       }
+
+      event.xany.type = ClientMessage;
+      event.xclient.display = dpy;
+      event.xclient.window = window;
+      event.xclient.message_type = XA_SCREENSAVER;
+      event.xclient.format = 32;
+      memset (&event.xclient.data, 0, sizeof(event.xclient.data));
+      event.xclient.data.l[0] = (long) command;
+      event.xclient.data.l[1] = arg1;
+      event.xclient.data.l[2] = arg2;
+      if (! XSendEvent (dpy, window, False, 0L, &event))
+       {
+         fprintf (stderr, "%s: XSendEvent(dpy, 0x%x ...) failed.\n",
+                  progname, (unsigned int) window);
+         return -1;
+       }
+    }
+  XSync (dpy, 0);
+  return 0;
+}
+
+
+static int
+xscreensaver_command_response (Display *dpy, Window window, Bool verbose_p)
+{
+  int fd = ConnectionNumber (dpy);
+  int timeout = 10;
+  int status;
+  fd_set fds;
+  struct timeval tv;
+
+  while (1)
+    {
+      FD_ZERO(&fds);
+      FD_SET(fd, &fds);
+      memset(&tv, 0, sizeof(tv));
+      tv.tv_sec = timeout;
+      status = select (fd+1, &fds, 0, &fds, &tv);
+
+      if (status < 0)
+       {
+         char buf[1024];
+         sprintf (buf, "%s: waiting for reply", progname);
+         perror (buf);
+         return status;
+       }
+      else if (status == 0)
+       {
+         fprintf (stderr, "%s: no response to command.\n", progname);
+         return -1;
+       }
+      else
+       {
+         XEvent event;
+         XNextEvent (dpy, &event);
+         if (event.xany.type == PropertyNotify &&
+             event.xproperty.state == PropertyNewValue &&
+             event.xproperty.atom == XA_SCREENSAVER_RESPONSE)
+           {
+             Status st2;
+             Atom type;
+             int format;
+             unsigned long nitems, bytesafter;
+             char *msg = 0;
+
+             old_handler = XSetErrorHandler (BadWindow_ehandler);
+             XSync (dpy, False);
+
+             st2 = XGetWindowProperty (dpy, window,
+                                       XA_SCREENSAVER_RESPONSE,
+                                       0, 1024, True,
+                                       AnyPropertyType,
+                                       &type, &format, &nitems, &bytesafter,
+                                       (unsigned char **) &msg);
+
+             if (got_badwindow)
+               {
+                 fprintf (stdout,
+                          "%s: xscreensaver window has been deleted.\n",
+                          progname);
+                 return 0;
+               }
+
+             if (st2 == Success && type != None)
+               {
+                 if (type != XA_STRING || format != 8)
+                   {
+                     fprintf (stderr,
+                              "%s: unrecognized response property.\n",
+                              progname);
+                     if (msg) XFree (msg);
+                     return -1;
+                   }
+                 else if (!msg || (msg[0] != '+' && msg[0] != '-'))
+                   {
+                     fprintf (stderr,
+                              "%s: unrecognized response message.\n",
+                              progname);
+                     if (msg) XFree (msg);
+                     return -1;
+                   }
+                 else
+                   {
+                     int ret = (msg[0] == '+' ? 0 : -1);
+                     if (verbose_p || ret != 0)
+                       fprintf ((ret < 0 ? stderr : stdout),
+                                "%s: %s\n",
+                                progname,
+                                msg+1);
+                     XFree (msg);
+                     return ret;
+                   }
+               }
+           }
+       }
+    }
+}
+
+
+int
+xscreensaver_command (Display *dpy, Atom command, long arg, Bool verbose_p)
+{
+  Window w = 0;
+  int status = send_xscreensaver_command (dpy, command, arg, &w);
+  if (status == 0)
+    status = xscreensaver_command_response (dpy, w, verbose_p);
+  fflush (stdout);
+  fflush (stderr);
+  return status;
+}
+
+
+void
+server_xscreensaver_version (Display *dpy,
+                            char **version_ret,
+                            char **user_ret,
+                            char **host_ret)
+{
+  Window window = find_screensaver_window (dpy, 0);
+
+  Atom type;
+  int format;
+  unsigned long nitems, bytesafter;
+
+  if (version_ret)
+    *version_ret = 0;
+  if (host_ret)
+    *host_ret = 0;
+
+  if (!window)
+    return;
+
+  if (version_ret)
+    {
+      char *v = 0;
+      XGetWindowProperty (dpy, window, XA_SCREENSAVER_VERSION, 0, 1,
+                         False, XA_STRING, &type, &format, &nitems,
+                         &bytesafter, (unsigned char **) &v);
+      if (v)
+       {
+         *version_ret = strdup (v);
+         XFree (v);
+       }
+    }
+
+  if (user_ret || host_ret)
+    {
+      char *id = 0;
+      const char *user = 0;
+      const char *host = 0;
+
+      XGetWindowProperty (dpy, window, XA_SCREENSAVER_ID, 0, 512,
+                         False, XA_STRING, &type, &format, &nitems,
+                         &bytesafter, (unsigned char **) &id);
+      if (id && *id)
+       {
+         const char *old_tag = " on host ";
+         const char *s = strstr (id, old_tag);
+         if (s)
+           {
+             /* found ID of the form "1234 on host xyz". */
+             user = 0;
+             host = s + strlen (old_tag);
+           }
+         else
+           {
+             char *o = 0, *p = 0, *c = 0;
+             o = strchr (id, '(');
+             if (o) p = strchr (o, '@');
+             if (p) c = strchr (p, ')');
+             if (c)
+               {
+                 /* found ID of the form "1234 (user@host)". */
+                 user = o+1;
+                 host = p+1;
+                 *p = 0;
+                 *c = 0;
+               }
+           }
+
+       }
+
+      if (user && *user && *user != '?')
+       *user_ret = strdup (user);
+      else
+       *user_ret = 0;
+
+      if (host && *host && *host != '?')
+       *host_ret = strdup (host);
+      else
+       *host_ret = 0;
+
+      if (id)
+       XFree (id);
+    }
+}
diff --git a/driver/remote.h b/driver/remote.h
new file mode 100644 (file)
index 0000000..d368e43
--- /dev/null
@@ -0,0 +1,24 @@
+/* xscreensaver-command, Copyright (c) 1991-1998
+ *  by 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
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation.  No representations are made about the suitability of this
+ * software for any purpose.  It is provided "as is" without express or 
+ * implied warranty.
+ */
+
+#ifndef _XSCREENSAVER_REMOTE_H_
+#define _XSCREENSAVER_REMOTE_H_
+
+extern int xscreensaver_command (Display *dpy, Atom command, long arg,
+                                Bool verbose_p);
+
+extern void server_xscreensaver_version (Display *dpy,
+                                        char **version_ret,
+                                        char **user_ret,
+                                        char **host_ret);
+
+#endif /* _XSCREENSAVER_REMOTE_H_ */
index 399f7df05ebc391402591f7fe9f1d0c277010ba7..1323565b775f0151508ababc37cc1351668ccb13 100644 (file)
@@ -37,7 +37,7 @@
 
 
 static const char *
-uid_gid_string(uid_t uid, gid_t gid)
+uid_gid_string (uid_t uid, gid_t gid)
 {
   static char buf[255];
   struct passwd *p = 0;
@@ -190,6 +190,11 @@ set_ids_by_number (uid_t uid, gid_t gid, char **message_ret)
    don't get special privileges.  (On some systems it is necessary to install
    this program as setuid root in order to read the passwd file to implement
    lock-mode.)
+
+     *** WARNING: DO NOT DISABLE ANY OF THE FOLLOWING CODE!
+         If you do so, you will open a security hole.  See the sections
+         of the xscreensaver manual titled "LOCKING AND ROOT LOGINS", 
+         and "USING XDM".
  */
 void
 hack_uid (saver_info *si)
@@ -211,9 +216,15 @@ hack_uid (saver_info *si)
        saver_exit (si, 1, 0);
   }
 
+
   /* Locking can't work when running as root, because we have no way of
      knowing what the user id of the logged in user is (so we don't know
      whose password to prompt for.)
+
+     *** WARNING: DO NOT DISABLE THIS CODE!
+         If you do so, you will open a security hole.  See the sections
+         of the xscreensaver manual titled "LOCKING AND ROOT LOGINS",
+         and "USING XDM".
    */
   if (getuid() == (uid_t) 0)
     {
@@ -221,11 +232,18 @@ hack_uid (saver_info *si)
       si->nolock_reason = "running as root";
     }
 
+
   /* If we're running as root, switch to a safer user.  This is above and
      beyond the fact that we've disabling locking, above -- the theory is
      that running graphics demos as root is just always a stupid thing
      to do, since they have probably never been security reviewed and are
      more likely to be buggy than just about any other kind of program.
+     (And that assumes non-malicious code.  There are also attacks here.)
+
+     *** WARNING: DO NOT DISABLE THIS CODE!
+         If you do so, you will open a security hole.  See the sections
+         of the xscreensaver manual titled "LOCKING AND ROOT LOGINS", 
+         and "USING XDM".
    */
   if (getuid() == (uid_t) 0)
     {
@@ -253,6 +271,11 @@ hack_uid (saver_info *si)
      and not normal end-users) then disable locking.  If it was possible,
      switching to "nobody" would be the thing to do, but only root itself has
      the privs to do that.
+
+     *** WARNING: DO NOT DISABLE THIS CODE!
+         If you do so, you will open a security hole.  See the sections
+         of the xscreensaver manual titled "LOCKING AND ROOT LOGINS",
+         and "USING XDM".
    */
   {
     uid_t uid = getuid ();             /* get it again */
index e715f4fc5921b983cd5c5e17ed1bd47f42d3589a..8f6fb011249ad9fd72dee71aeaf4b896ac051cd9 100644 (file)
@@ -94,49 +94,15 @@ string_width (XFontStruct *font, char *s)
 }
 
 
-static void
-send_self_clientmessage (saver_info *si, Atom command)
-{
-  Display *dpy = si->dpy;
-  Window window = si->default_screen->screensaver_window;
-  XEvent event;
-  event.xany.type = ClientMessage;
-  event.xclient.display = si->dpy;
-  event.xclient.window = window;
-  event.xclient.message_type = XA_SCREENSAVER;
-  event.xclient.format = 32;
-  memset (&event.xclient.data, 0, sizeof(event.xclient.data));
-  event.xclient.data.l[0] = (long) command;
-  if (! XSendEvent (dpy, window, False, 0L, &event))
-    fprintf (stderr, "%s: XSendEvent(dpy, 0x%x ...) failed.\n",
-            progname, (unsigned int) window);
-}
-
-
-static void
-get_help (saver_info *si)
-{
-  saver_preferences *p = &si->prefs;
-
-  if (!p->help_url || !*p->help_url)
-    fprintf (stderr, "%s: no Help URL has been specified.\n", blurb());
-  else if (!p->load_url_command || !*p->load_url_command)
-    fprintf (stderr, "%s: no URL-loading command has been specified.\n",
-            blurb());
-  else
-    {
-      char *buf = (char *) malloc (strlen(p->load_url_command) +
-                                  (strlen(p->help_url) * 2) + 10);
-      sprintf (buf, p->load_url_command, p->help_url, p->help_url);
-      system (buf);
-    }
-}
-
 static void update_splash_window (saver_info *si);
 static void draw_splash_window (saver_info *si);
 static void destroy_splash_window (saver_info *si);
 static void unsplash_timer (XtPointer closure, XtIntervalId *id);
 
+static void do_demo (saver_info *si);
+static void do_prefs (saver_info *si);
+static void do_help (saver_info *si);
+
 
 struct splash_dialog_data {
   XtIntervalId timer;
@@ -676,9 +642,9 @@ handle_splash_event (saver_info *si, XEvent *event)
              destroy_splash_window (si);
              switch (which)
                {
-               case 1: send_self_clientmessage (si, XA_DEMO); break;
-               case 2: send_self_clientmessage (si, XA_PREFS); break;
-               case 3: get_help (si); break;
+               case 1: do_demo (si); break;
+               case 2: do_prefs (si); break;
+               case 3: do_help (si); break;
                default: abort();
                }
            }
@@ -699,3 +665,92 @@ unsplash_timer (XtPointer closure, XtIntervalId *id)
   if (si && si->sp_data)
     destroy_splash_window (si);
 }
+
+\f
+/* Button callbacks */
+
+#ifdef VMS
+# define pid_t int
+# define fork  vfork
+#endif /* VMS */
+
+static void
+fork_and_exec (saver_info *si, const char *command, const char *desc)
+{
+  saver_preferences *p = &si->prefs;
+  pid_t forked;
+  char buf [512];
+  char *av[5];
+  int ac;
+
+  if (!command || !*command)
+    {
+      fprintf (stderr, "%s: no %s command has been specified.\n",
+              blurb(), desc);
+      return;
+    }
+
+  switch ((int) (forked = fork ()))
+    {
+    case -1:
+      sprintf (buf, "%s: couldn't fork", blurb());
+      perror (buf);
+      break;
+
+    case 0:
+      close (ConnectionNumber (si->dpy));              /* close display fd */
+      hack_subproc_environment (si->default_screen);   /* set $DISPLAY */
+      ac = 0;
+      av [ac++] = (char *) p->shell;
+      av [ac++] = (char *) "-c";
+      av [ac++] = (char *) command;
+      av [ac]   = 0;
+      execvp (av[0], av);                              /* shouldn't return. */
+
+      sprintf (buf, "%s: execvp(\"%s\", \"%s\", \"%s\") failed",
+              blurb(), av[0], av[1], av[2]);
+      perror (buf);
+      fflush (stderr);
+      fflush (stdout);
+      exit (1);                         /* Note that this only exits a child fork.  */
+      break;
+
+    default:
+      /* parent fork. */
+      break;
+    }
+}
+
+
+static void
+do_demo (saver_info *si)
+{
+  saver_preferences *p = &si->prefs;
+  fork_and_exec (si, p->demo_command, "demo-mode");
+}
+
+static void
+do_prefs (saver_info *si)
+{
+  saver_preferences *p = &si->prefs;
+  fork_and_exec (si, p->prefs_command, "preferences");
+}
+
+static void
+do_help (saver_info *si)
+{
+  saver_preferences *p = &si->prefs;
+  char *help_command;
+
+  if (!p->help_url || !*p->help_url)
+    {
+      fprintf (stderr, "%s: no Help URL has been specified.\n", blurb());
+      return;
+    }
+
+  help_command = (char *) malloc (strlen (p->load_url_command) +
+                                 (strlen (p->help_url) * 2) + 10);
+  sprintf (help_command, p->load_url_command, p->help_url, p->help_url);
+  fork_and_exec (si, help_command, "URL-loading");
+  free (help_command);
+}
index 3f43139860243883555f9a910c20f7155c579010..a9fec53c0bf5d512d0d35d0359951417fb0c9ad5 100644 (file)
@@ -71,9 +71,6 @@ extern int kill (pid_t, int);         /* signal() is in sys/signal.h... */
 
 extern saver_info *global_si_kludge;   /* I hate C so much... */
 
-static void hack_subproc_environment (saver_screen_info *ssi);
-
-
 static void
 nice_subproc (int nice_level)
 {
@@ -248,7 +245,8 @@ exec_screenhack (saver_info *si, const char *command)
   saver_preferences *p = &si->prefs;
 
 #ifndef VMS
-  Bool hairy_p = !!strpbrk (command, "*?$&!<>[];`'\\\"");
+  Bool hairy_p = !!strpbrk (command, "*?$&!<>[];`'\\\"=");
+  /* note: = is in the above because of the sh syntax "FOO=bar cmd". */
 
   if (p->verbose_p)
     fprintf (stderr, "%s: spawning \"%s\" in pid %lu%s.\n",
@@ -702,6 +700,14 @@ init_sigchld (void)
 
 \f
 
+static Bool
+hack_enabled_p (const char *hack)
+{
+  const char *s = hack;
+  while (isspace(*s)) s++;
+  return (*s != '-');
+}
+
 static Bool
 select_visual_of_hack (saver_screen_info *ssi, const char *hack)
 {
@@ -712,6 +718,9 @@ select_visual_of_hack (saver_screen_info *ssi, const char *hack)
   const char *in = hack;
   char *out = vis;
   while (isspace(*in)) in++;           /* skip whitespace */
+  if (*in == '-') in++;                        /* skip optional "-" */
+  while (isspace(*in)) in++;           /* skip whitespace */
+
   while (!isspace(*in) && *in != ':')
     *out++ = *in++;                    /* snarf first token */
   while (isspace(*in)) in++;           /* skip whitespace */
@@ -722,12 +731,12 @@ select_visual_of_hack (saver_screen_info *ssi, const char *hack)
   else
     selected = select_visual(ssi, 0);
 
-  if (!selected && (p->verbose_p || si->demo_mode_p))
+  if (!selected && (p->verbose_p || si->demoing_p))
     {
       if (*in == ':') in++;
       while (isspace(*in)) in++;
       fprintf (stderr,
-              (si->demo_mode_p
+              (si->demoing_p
                ? "%s: warning, no \"%s\" visual for \"%s\".\n"
                : "%s: no \"%s\" visual; skipping \"%s\".\n"),
               blurb(), (vis ? vis : "???"), in);
@@ -745,61 +754,76 @@ spawn_screenhack_1 (saver_screen_info *ssi, Bool first_time_p)
   raise_window (si, first_time_p, True, False);
   XFlush (si->dpy);
 
-  if (p->screenhacks_count || si->demo_mode_p)
+  if (p->screenhacks_count)
     {
       char *hack;
       pid_t forked;
       char buf [255];
       int new_hack;
+      int retry_count = 0;
+      Bool force = False;
 
-      if (si->demo_mode_p)
-       {
-         hack = si->demo_hack;
+    AGAIN:
+
+      if (p->screenhacks_count == 1)
+       /* If there is only one hack in the list, there is no choice. */
+       new_hack = 0;
+
+      else if (si->selection_mode == -1)
+       /* Select the next hack, wrapping. */
+       new_hack = (ssi->current_hack + 1) % p->screenhacks_count;
+
+      else if (si->selection_mode == -2)
+       /* Select the previous hack, wrapping. */
+       new_hack = ((ssi->current_hack + p->screenhacks_count - 1)
+                   % p->screenhacks_count);
 
-         /* Ignore visual-selection failure if in demo mode. */
-         (void) select_visual_of_hack (ssi, hack);
+      else if (si->selection_mode > 0)
+       /* Select a specific hack, by number.  No negotiation. */
+       {
+         new_hack = ((si->selection_mode - 1) % p->screenhacks_count);
+         force = True;
        }
       else
        {
-         int retry_count = 0;
-
-       AGAIN:
-         if (p->screenhacks_count == 1)
-           new_hack = 0;
-         else if (si->selection_mode == -1)
-           new_hack = (ssi->current_hack + 1) % p->screenhacks_count;
-         else if (si->selection_mode == -2)
-           new_hack = ((ssi->current_hack + p->screenhacks_count - 1)
-                       % p->screenhacks_count);
-         else if (si->selection_mode > 0)
-           new_hack = ((si->selection_mode - 1) % p->screenhacks_count);
-         else
-           while ((new_hack = random () % p->screenhacks_count)
-                  == ssi->current_hack)
-             ;
-         ssi->current_hack = new_hack;
-         hack = p->screenhacks[ssi->current_hack];
+         /* Select a random hack (but not the one we just ran.) */
+         while ((new_hack = random () % p->screenhacks_count)
+                == ssi->current_hack)
+           ;
+       }
 
-         if (!select_visual_of_hack (ssi, hack))
+      ssi->current_hack = new_hack;
+      hack = p->screenhacks[ssi->current_hack];
+
+      /* If the hack is disabled, or there is no visual for this hack,
+        then try again (move forward, or backward, or re-randomize.)
+        Unless this hack was specified explicitly, in which case,
+        use it regardless.
+       */
+      if (!force &&
+         (!hack_enabled_p (hack) ||
+          !select_visual_of_hack (ssi, hack)))
+       {
+         if (++retry_count > (p->screenhacks_count*4))
            {
-             if (++retry_count > (p->screenhacks_count*4))
-               {
-                 /* Uh, oops.  Odds are, there are no suitable visuals,
-                    and we're looping.  Give up.  (This is totally lame,
-                    what we should do is make a list of suitable hacks at
-                    the beginning, then only loop over them.)
-                 */
-                 if (p->verbose_p)
-                   fprintf(stderr,
-                           "%s: no suitable visuals for these programs.\n",
-                           blurb());
-                 return;
-               }
-             else
-               goto AGAIN;
+             /* Uh, oops.  Odds are, there are no suitable visuals,
+                and we're looping.  Give up.  (This is totally lame,
+                what we should do is make a list of suitable hacks at
+                the beginning, then only loop over them.)
+             */
+             if (p->verbose_p)
+               fprintf(stderr,
+                       "%s: no suitable visuals for these programs.\n",
+                       blurb());
+             return;
            }
+         else
+           goto AGAIN;
        }
 
+      /* Turn off "next" and "prev" modes now, but "demo" mode is only
+        turned off by explicit action.
+       */
       if (si->selection_mode < 0)
        si->selection_mode = 0;
 
@@ -809,6 +833,8 @@ spawn_screenhack_1 (saver_screen_info *ssi, Bool first_time_p)
       {
        char *in = hack;
        while (isspace(*in)) in++;                      /* skip whitespace */
+       if (*in == '-') in++;                           /* skip optional "-" */
+       while (isspace(*in)) in++;                      /* skip whitespace */
        hack = in;
        while (!isspace(*in) && *in != ':') in++;       /* snarf first token */
        while (isspace(*in)) in++;                      /* skip whitespace */
@@ -958,7 +984,7 @@ hack_environment (saver_info *si)
 }
 
 
-static void
+void
 hack_subproc_environment (saver_screen_info *ssi)
 {
   /* Store $DISPLAY into the environment, so that the $DISPLAY variable that
@@ -1007,7 +1033,6 @@ static char **saved_argv;
 void
 save_argv (int argc, char **argv)
 {
-  /* Leave room for one more argument, the -initial-demo-mode switch. */
   saved_argv = (char **) calloc (argc+2, sizeof (char *));
   saved_argv [argc] = 0;
   while (argc--)
@@ -1018,45 +1043,24 @@ save_argv (int argc, char **argv)
     }
 }
 
-/* Modifies saved_argv to either contain or not contain "-initial-demo-mode".
+
+/* Re-execs the process with the arguments in saved_argv.
+   Does not return unless there was an error.
  */
-static void
-hack_saved_argv (Bool demo_mode_p)
+void
+restart_process (saver_info *si)
 {
-  static char *demo_mode_switch = "-initial-demo-mode";
-
-  if (demo_mode_p)             /* We want the switch to be in the args. */
-    {
-      /* See if the switch is there already.  If so, we're done. */
-      int i;
-      for (i = 0; saved_argv[i]; i++)
-       if (!strcmp (saved_argv[i], demo_mode_switch))
-         return;
-
-      /* If it wasn't there, add it to the end.  save_argv() made room. */
-      saved_argv [i] = demo_mode_switch;
-      saved_argv [i+1] = 0;
-    }
-  else                         /* We want the switch to not be in the args. */
+  if (si->prefs.verbose_p)
     {
       int i;
+      fprintf (real_stderr, "%s: re-executing", blurb());
       for (i = 0; saved_argv[i]; i++)
-       while (!strcmp (saved_argv [i], demo_mode_switch))
-         {
-           int j;
-           for (j = i; saved_argv[j]; j++)
-             saved_argv [j] = saved_argv [j+1];
-         }
+       fprintf (real_stderr, " %s", saved_argv[i]);
+      fprintf (real_stderr, "\n");
     }
-}
-
+  describe_uids (si, real_stderr);
+  fprintf (real_stderr, "\n");
 
-/* Re-execs the process with the arguments in saved_argv.
-   Does not return unless there was an error.
- */
-static void
-restart_process_1 (saver_info *si)
-{
   fflush (real_stdout);
   fflush (real_stderr);
   execvp (saved_argv [0], saved_argv); /* shouldn't return */
@@ -1068,26 +1072,3 @@ restart_process_1 (saver_info *si)
   }
   XBell(si->dpy, 0);
 }
-
-
-/* Re-execs the process with the arguments in saved_argv,
-   minus -initial-demo-mode.
-   Does not return unless there was an error.
- */
-void
-restart_process (saver_info *si)
-{
-  hack_saved_argv (True);
-  restart_process_1 (si);
-}
-
-/* Re-execs the process with the arguments in saved_argv,
-   plus -initial-demo-mode.
-   Does not return unless there was an error.
- */
-void
-demo_mode_restart_process (saver_info *si)
-{
-  hack_saved_argv (False);
-  restart_process_1 (si);
-}
index 318c9453d9e767dca6484393e7f71e30a9079dc2..9510f803aefd6cdfa6538db165d0f3b0d0daa68d 100644 (file)
@@ -14,7 +14,7 @@
    itself.
  */
 
-#define WHICH 0
+#define WHICH 2
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -39,26 +39,20 @@ saver_info *global_si_kludge;
 
 FILE *real_stderr, *real_stdout;
 
-void reset_stderr(saver_screen_info *ssi) {}
-void clear_stderr(saver_screen_info *ssi) {}
-void reset_watchdog_timer(saver_info *si, Bool on_p) {}
 void monitor_power_on (saver_info *si) {}
-void grab_keyboard_and_mouse (saver_info *si, Window w, Cursor c) {}
-void ungrab_keyboard_and_mouse (saver_info *si) {}
-Bool select_visual (saver_screen_info *ssi, const char *v) { return False; }
-void raise_window (saver_info *si, Bool i, Bool b, Bool d) {}
-void restore_real_vroot (saver_info *si) {}
-void saver_exit (saver_info *si, int status, const char *core) { exit(status);}
-const char * signal_name(int signal) { return "???"; }
 Bool monitor_powered_on_p (saver_info *si) { return True; }
-void start_notice_events_timer (saver_info *si, Window w) {}
 void initialize_screensaver_window (saver_info *si) {}
+void raise_window (saver_info *si, Bool i, Bool b, Bool d) {}
 void blank_screen (saver_info *si) {}
 void unblank_screen (saver_info *si) {}
+Bool select_visual (saver_screen_info *ssi, const char *v) { return False; }
+Bool window_exists_p (Display *dpy, Window window) {return True;}
+void start_notice_events_timer (saver_info *si, Window w) {}
 Bool handle_clientmessage (saver_info *si, XEvent *e, Bool u) { return False; }
 int BadWindow_ehandler (Display *dpy, XErrorEvent *error) { exit(1); }
-int write_init_file (saver_info *si) { return 0;}
-Bool window_exists_p (Display *dpy, Window window) {return True;}
+const char *signal_name(int signal) { return "???"; }
+void restore_real_vroot (saver_info *si) {}
+void saver_exit (saver_info *si, int status, const char *core) { exit(status);}
 
 const char *blurb(void) { return progname; }
 Atom XA_SCREENSAVER, XA_DEMO, XA_PREFS;
@@ -76,163 +70,6 @@ idle_timer (XtPointer closure, XtIntervalId *id)
 }
 
 
-static char *
-reformat_hack (const char *hack)
-{
-  int i;
-  const char *in = hack;
-  int indent = 13;
-  char *h2 = (char *) malloc(strlen(in) + indent + 2);
-  char *out = h2;
-
-  while (isspace(*in)) in++;           /* skip whitespace */
-  while (*in && !isspace(*in) && *in != ':')
-    *out++ = *in++;                    /* snarf first token */
-  while (isspace(*in)) in++;           /* skip whitespace */
-
-  if (*in == ':')
-    *out++ = *in++;                    /* copy colon */
-  else
-    {
-      in = hack;
-      out = h2;                                /* reset to beginning */
-    }
-
-  *out = 0;
-
-  while (isspace(*in)) in++;           /* skip whitespace */
-  for (i = strlen(h2); i < indent; i++)        /* indent */
-    *out++ = ' ';
-
-  /* copy the rest of the line. */
-  while (*in)
-    {
-      /* shrink all whitespace to one space, for the benefit of the "demo"
-        mode display.  We only do this when we can easily tell that the
-        whitespace is not significant (no shell metachars).
-       */
-      switch (*in)
-       {
-       case '\'': case '"': case '`': case '\\':
-         {
-           /* Metachars are scary.  Copy the rest of the line unchanged. */
-           while (*in)
-             *out++ = *in++;
-         }
-         break;
-       case ' ': case '\t':
-         {
-           while (*in == ' ' || *in == '\t')
-             in++;
-           *out++ = ' ';
-         }
-         break;
-       default:
-         *out++ = *in++;
-         break;
-       }
-    }
-  *out = 0;
-
-  /* strip trailing whitespace. */
-  out = out-1;
-  while (out > h2 && (*out == ' ' || *out == '\t' || *out == '\n'))
-    *out-- = 0;
-
-  return h2;
-}
-
-
-static void
-get_screenhacks (saver_info *si)
-{
-  saver_preferences *p = &si->prefs;
-  int i = 0;
-  int start = 0;
-  int end = 0;
-  int size;
-  char *d;
-
-  d = get_string_resource ("monoPrograms", "MonoPrograms");
-  if (d && !*d) { free(d); d = 0; }
-  if (!d)
-    d = get_string_resource ("colorPrograms", "ColorPrograms");
-  if (d && !*d) { free(d); d = 0; }
-
-  if (d)
-    {
-      fprintf (stderr,
-       "%s: the `monoPrograms' and `colorPrograms' resources are obsolete;\n\
-       see the manual for details.\n", blurb());
-      free(d);
-    }
-
-  d = get_string_resource ("programs", "Programs");
-
-  if (p->screenhacks)
-    {
-      for (i = 0; i < p->screenhacks_count; i++)
-       if (p->screenhacks[i])
-         free (p->screenhacks[i]);
-      free(p->screenhacks);
-      p->screenhacks = 0;
-    }
-
-  if (!d || !*d)
-    {
-      p->screenhacks_count = 0;
-      p->screenhacks = 0;
-      return;
-    }
-
-  size = strlen (d);
-
-
-  /* Count up the number of newlines (which will be equal to or larger than
-     the number of hacks.)
-   */
-  i = 0;
-  for (i = 0; d[i]; i++)
-    if (d[i] == '\n')
-      i++;
-  i++;
-
-  p->screenhacks = (char **) calloc (sizeof (char *), i+1);
-
-  /* Iterate over the lines in `d' (the string with newlines)
-     and make new strings to stuff into the `screenhacks' array.
-   */
-  p->screenhacks_count = 0;
-  while (start < size)
-    {
-      /* skip forward over whitespace. */
-      while (d[start] == ' ' || d[start] == '\t' || d[start] == '\n')
-       start++;
-
-      /* skip forward to newline or end of string. */
-      end = start;
-      while (d[end] != 0 && d[end] != '\n')
-       end++;
-
-      /* null terminate. */
-      d[end] = 0;
-
-      p->screenhacks[p->screenhacks_count++] = reformat_hack (d + start);
-      if (p->screenhacks_count >= i)
-       abort();
-
-      start = end+1;
-    }
-
-  if (p->screenhacks_count == 0)
-    {
-      free (p->screenhacks);
-      p->screenhacks = 0;
-    }
-}
-
-
-
 static char *fallback[] = {
 #include "XScreenSaver_ad.h"
  0
@@ -281,7 +118,7 @@ main (int argc, char **argv)
                                    0, 0);
 
   si->dpy = XtDisplay (toplevel_shell);
-  si->db = XtDatabase (si->dpy);
+  p->db = XtDatabase (si->dpy);
   si->default_screen->toplevel_shell = toplevel_shell;
   si->default_screen->screen = XtScreen(toplevel_shell);
   si->default_screen->default_visual =
@@ -290,34 +127,10 @@ main (int argc, char **argv)
   si->default_screen->screensaver_window =
     RootWindowOfScreen(si->default_screen->screen);
 
-  db = si->db;
+  db = p->db;
   XtGetApplicationNameAndClass (si->dpy, &progname, &progclass);
 
-  p->debug_p = True;
-  p->verbose_p = True;
-  p->timestamp_p = True;
-  p->lock_p = True;
-
-  p->fade_p        = get_boolean_resource ("fade", "Boolean");
-  p->unfade_p      = get_boolean_resource ("unfade", "Boolean");
-  p->fade_seconds   = 1000 * get_seconds_resource ("fadeSeconds", "Time");
-  p->fade_ticks            = get_integer_resource ("fadeTicks", "Integer");
-  p->install_cmap_p = get_boolean_resource ("installColormap", "Boolean");
-  p->nice_inferior  = get_integer_resource ("nice", "Nice");
-
-  p->initial_delay   = 1000 * get_seconds_resource ("initialDelay", "Time");
-  p->splash_duration = 1000 * get_seconds_resource ("splashDuration", "Time");
-  p->timeout         = 1000 * get_minutes_resource ("timeout", "Time");
-  p->lock_timeout    = 1000 * get_minutes_resource ("lockTimeout", "Time");
-  p->cycle           = 1000 * get_minutes_resource ("cycle", "Time");
-  p->passwd_timeout  = 1000 * get_seconds_resource ("passwdTimeout", "Time");
-  p->passwd_timeout = 1000 * get_seconds_resource ("passwdTimeout", "Time");
-  p->splash_duration = 1000 * get_seconds_resource ("splashDuration", "Time");
-  p->shell = get_string_resource ("bourneShell", "BourneShell");
-  p->help_url = get_string_resource("helpURL", "URL");
-  p->load_url_command = get_string_resource("loadURL", "LoadURL");
-
-  get_screenhacks(si);
+  load_init_file (&si->prefs);
 
   while (1)
     {
@@ -346,7 +159,6 @@ main (int argc, char **argv)
        sleep (1);
       }
 #else
-      si->demo_mode_p = True;
       make_screenhack_dialog (si);
       XtAppMainLoop(si->app);
 #endif
index aba6d5a3f0d421973fa1b3ef198ae9ce6bb0d13d..c909287cc2968290ced54bb7fb8cb2b173df555a 100644 (file)
@@ -242,7 +242,8 @@ 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 ();  /* no cycle timer when inactive */
@@ -468,11 +469,25 @@ sleep_until_idle (saver_info *si, Bool until_idle_p)
        /* If any widgets want to handle this event, let them. */
        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)
+             /* 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:
@@ -484,15 +499,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];
@@ -504,11 +517,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)
@@ -516,20 +527,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
 
@@ -539,11 +546,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;
@@ -551,11 +556,9 @@ 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;
          }
@@ -620,29 +623,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);
        }
     }
 }
index 2d975475f0ece5a0a7cde66fd4e1943f9c80b256..470ec10ba7800eea36e34a6ef4a9dccd9e8d6f5f 100644 (file)
 # include "vms-gtod.h"         /* for gettimeofday() */
 #endif /* VMS */
 
-# ifdef HAVE_UNAME
-#  include <sys/utsname.h>     /* for uname() */
-# endif /* HAVE_UNAME */
+#ifndef VMS
+# include <pwd.h>              /* for getpwuid() */
+#else /* VMS */
+# include "vms-pwd.h"
+#endif /* VMS */
+
+#ifdef HAVE_UNAME
+# include <sys/utsname.h>      /* for uname() */
+#endif /* HAVE_UNAME */
 
 #include <stdio.h>
 #include <X11/Xproto.h>                /* for CARD32 */
@@ -173,31 +179,34 @@ ungrab_mouse(saver_info *si)
 }
 
 
-void
+Bool
 grab_keyboard_and_mouse (saver_info *si, Window window, Cursor cursor)
 {
-  Status status;
+  Status mstatus, kstatus;
   XSync (si->dpy, False);
 
-  status = grab_kbd (si, window);
-  if (status != GrabSuccess)
+  kstatus = grab_kbd (si, window);
+  if (kstatus != GrabSuccess)
     {  /* try again in a second */
       sleep (1);
-      status = grab_kbd (si, window);
-      if (status != GrabSuccess)
+      kstatus = grab_kbd (si, window);
+      if (kstatus != GrabSuccess)
        fprintf (stderr, "%s: couldn't grab keyboard!  (%s)\n",
-                blurb(), grab_string(status));
+                blurb(), grab_string(kstatus));
     }
 
-  status = grab_mouse (si, window, cursor);
-  if (status != GrabSuccess)
+  mstatus = grab_mouse (si, window, cursor);
+  if (mstatus != GrabSuccess)
     {  /* try again in a second */
       sleep (1);
-      status = grab_mouse (si, window, cursor);
-      if (status != GrabSuccess)
+      mstatus = grab_mouse (si, window, cursor);
+      if (mstatus != GrabSuccess)
        fprintf (stderr, "%s: couldn't grab pointer!  (%s)\n",
-                blurb(), grab_string(status));
+                blurb(), grab_string(mstatus));
     }
+
+  return (kstatus == GrabSuccess ||
+         mstatus == GrabSuccess);
 }
 
 void
@@ -357,6 +366,16 @@ save_real_vroot (saver_screen_info *ssi)
   Window root = RootWindowOfScreen (screen);
   Window root2, parent, *kids;
   unsigned int nkids;
+  XErrorHandler old_handler;
+
+  /* It's possible that a window might be deleted between our call to
+     XQueryTree() and our call to XGetWindowProperty().  Don't die if
+     that happens (but just ignore that window, it's not the one we're
+     interested in anyway.)
+   */
+  XSync (dpy, False);
+  old_handler = XSetErrorHandler (BadWindow_ehandler);
+  XSync (dpy, False);
 
   ssi->real_vroot = 0;
   ssi->real_vroot_value = 0;
@@ -392,6 +411,10 @@ save_real_vroot (saver_screen_info *ssi)
       ssi->real_vroot_value = *vrootP;
     }
 
+  XSync (dpy, False);
+  XSetErrorHandler (old_handler);
+  XSync (dpy, False);
+
   if (ssi->real_vroot)
     {
       handle_signals (si, True);
@@ -676,6 +699,71 @@ window_exists_p (Display *dpy, Window window)
   return (xgwa.screen != 0);
 }
 
+static void
+store_saver_id (saver_screen_info *ssi)
+{
+  XClassHint class_hints;
+  saver_info *si = ssi->global;
+  unsigned long pid = (unsigned long) getpid ();
+  char buf[20];
+  struct passwd *p = getpwuid (getuid ());
+  const char *name, *host;
+  char *id;
+  
+  /* First store the name and class on the window.
+   */
+  class_hints.res_name = progname;
+  class_hints.res_class = progclass;
+  XSetClassHint (si->dpy, ssi->screensaver_window, &class_hints);
+  XStoreName (si->dpy, ssi->screensaver_window, "screensaver");
+
+  /* Then store the xscreensaver version number.
+   */
+  XChangeProperty (si->dpy, ssi->screensaver_window,
+                  XA_SCREENSAVER_VERSION,
+                  XA_STRING, 8, PropModeReplace,
+                  (unsigned char *) si->version,
+                  strlen (si->version));
+
+  /* Now store the XSCREENSAVER_ID property, that says what user and host
+     xscreensaver is running as.
+   */
+
+  if (p && p->pw_name && *p->pw_name)
+    name = p->pw_name;
+  else if (p)
+    {
+      sprintf (buf, "%lu", (unsigned long) p->pw_uid);
+      name = buf;
+    }
+  else
+    name = "???";
+
+# if defined(HAVE_UNAME)
+  {
+    struct utsname uts;
+    if (uname (&uts) < 0)
+      host = "???";
+    else
+      host = uts.nodename;
+  }
+# elif defined(VMS)
+  host = getenv("SYS$NODE");
+# else  /* !HAVE_UNAME && !VMS */
+  host = "???";
+# endif /* !HAVE_UNAME && !VMS */
+
+  id = (char *) malloc (strlen(name) + strlen(host) + 50);
+  sprintf (id, "%lu (%s@%s)", pid, name, host);
+
+  XChangeProperty (si->dpy, ssi->screensaver_window,
+                  XA_SCREENSAVER_ID, XA_STRING,
+                  8, PropModeReplace,
+                  (unsigned char *) id, strlen (id));
+  free (id);
+}
+
+
 static void
 initialize_screensaver_window_1 (saver_screen_info *ssi)
 {
@@ -689,12 +777,10 @@ initialize_screensaver_window_1 (saver_screen_info *ssi)
      its own set of problems...
    */
   XColor black;
-  XClassHint class_hints;
   XSetWindowAttributes attrs;
   unsigned long attrmask;
   int width = WidthOfScreen (ssi->screen);
   int height = HeightOfScreen (ssi->screen);
-  char id [2048];
   static Bool printed_visual_info = False;  /* only print the message once. */
 
   black.red = black.green = black.blue = 0;
@@ -709,7 +795,8 @@ initialize_screensaver_window_1 (saver_screen_info *ssi)
     {
       if (! ssi->cmap)
        {
-         ssi->cmap = XCreateColormap (si->dpy, RootWindowOfScreen (ssi->screen),
+         ssi->cmap = XCreateColormap (si->dpy,
+                                      RootWindowOfScreen (ssi->screen),
                                      ssi->current_visual, AllocNone);
          if (! XAllocColor (si->dpy, ssi->cmap, &black)) abort ();
          ssi->black_pixel = black.pixel;
@@ -848,68 +935,28 @@ initialize_screensaver_window_1 (saver_screen_info *ssi)
                 blurb(), (unsigned long) ssi->screensaver_window);
     }
 
-#ifdef HAVE_MIT_SAVER_EXTENSION
-  if (!p->use_mit_saver_extension ||
-      window_exists_p (si->dpy, ssi->screensaver_window))
-    /* When using the MIT-SCREEN-SAVER extension, the window pointed to
-       by screensaver_window only exists while the saver is active.
-       So we must be careful to only try and manipulate it while it
-       exists...
-       (#### The above comment would be true if the MIT extension actually
-       worked, but it's not true today -- see `server_mit_saver_window'.)
-     */
-#endif /* HAVE_MIT_SAVER_EXTENSION */
-    {
-      class_hints.res_name = progname;
-      class_hints.res_class = progclass;
-      XSetClassHint (si->dpy, ssi->screensaver_window, &class_hints);
-      XStoreName (si->dpy, ssi->screensaver_window, "screensaver");
-      XChangeProperty (si->dpy, ssi->screensaver_window,
-                      XA_SCREENSAVER_VERSION,
-                      XA_STRING, 8, PropModeReplace,
-                      (unsigned char *) si->version,
-                      strlen (si->version));
-
-      sprintf (id, "%lu on host ", (unsigned long) getpid ());
 
-# if defined(HAVE_UNAME)
-      {
-       struct utsname uts;
-       if (uname (&uts) < 0)
-         strcat (id, "???");
-       else
-         strcat (id, uts.nodename);
-      }
-# elif defined(VMS)
-      strcat (id, getenv("SYS$NODE"));
-# else  /* !HAVE_UNAME && !VMS */
-      strcat (id, "???");
-# endif /* !HAVE_UNAME && !VMS */
+  store_saver_id (ssi);
 
-      XChangeProperty (si->dpy, ssi->screensaver_window,
-                      XA_SCREENSAVER_ID, XA_STRING,
-                      8, PropModeReplace, (unsigned char *) id, strlen (id));
+  if (!ssi->cursor)
+    {
+      Pixmap bit;
+      bit = XCreatePixmapFromBitmapData (si->dpy, ssi->screensaver_window,
+                                        "\000", 1, 1,
+                                        BlackPixelOfScreen (ssi->screen),
+                                        BlackPixelOfScreen (ssi->screen),
+                                        1);
+      ssi->cursor = XCreatePixmapCursor (si->dpy, bit, bit, &black, &black,
+                                        0, 0);
+      XFreePixmap (si->dpy, bit);
+    }
 
-      if (!ssi->cursor)
-       {
-         Pixmap bit;
-         bit = XCreatePixmapFromBitmapData (si->dpy, ssi->screensaver_window,
-                                            "\000", 1, 1,
-                                            BlackPixelOfScreen (ssi->screen),
-                                            BlackPixelOfScreen (ssi->screen),
-                                            1);
-         ssi->cursor = XCreatePixmapCursor (si->dpy, bit, bit, &black, &black,
-                                            0, 0);
-         XFreePixmap (si->dpy, bit);
-       }
+  XSetWindowBackground (si->dpy, ssi->screensaver_window, ssi->black_pixel);
 
-      XSetWindowBackground (si->dpy, ssi->screensaver_window,
-                           ssi->black_pixel);
-      if (si->demo_mode_p)
-       XUndefineCursor (si->dpy, ssi->screensaver_window);
-      else
-       XDefineCursor (si->dpy, ssi->screensaver_window, ssi->cursor);
-    }
+  if (si->demoing_p)
+    XUndefineCursor (si->dpy, ssi->screensaver_window);
+  else
+    XDefineCursor (si->dpy, ssi->screensaver_window, ssi->cursor);
 }
 
 void
@@ -928,10 +975,13 @@ raise_window (saver_info *si,
   saver_preferences *p = &si->prefs;
   int i;
 
+  if (si->demoing_p)
+    inhibit_fade = True;
+
   initialize_screensaver_window (si);
   reset_watchdog_timer (si, True);
 
-  if (p->fade_p && si->fading_possible_p && !inhibit_fade && !si->demo_mode_p)
+  if (p->fade_p && p->fading_possible_p && !inhibit_fade)
     {
       Window *current_windows = (Window *)
        calloc(sizeof(Window), si->nscreens);
@@ -1030,7 +1080,9 @@ blank_screen (saver_info *si)
   grab_keyboard_and_mouse (si,
                           /*si->screens[0].screensaver_window,*/
                           RootWindowOfScreen(si->screens[0].screen),
-                          (si->demo_mode_p ? 0 : si->screens[0].cursor));
+                          (si->demoing_p
+                           ? 0
+                           : si->screens[0].cursor));
 
   for (i = 0; i < si->nscreens; i++)
     {
@@ -1064,6 +1116,7 @@ void
 unblank_screen (saver_info *si)
 {
   saver_preferences *p = &si->prefs;
+  Bool unfade_p = (p->fading_possible_p && p->unfade_p);
   int i;
 
   monitor_power_on (si);
@@ -1071,7 +1124,10 @@ unblank_screen (saver_info *si)
   store_activate_time (si, True);
   reset_watchdog_timer (si, False);
 
-  if (p->unfade_p && si->fading_possible_p && !si->demo_mode_p)
+  if (si->demoing_p)
+    unfade_p = False;
+
+  if (unfade_p)
     {
       Window *current_windows = (Window *)
        calloc(sizeof(Window), si->nscreens);
@@ -1296,9 +1352,11 @@ select_visual (saver_screen_info *ssi, const char *visual_name)
       if (old_w == si->mouse_grab_window)
        {
          XGrabServer (si->dpy);                /* ############ DANGER! */
-         ungrab_mouse(si);
-         grab_mouse(si, ssi->screensaver_window,
-                    (si->demo_mode_p ? 0 : ssi->cursor));
+         ungrab_mouse (si);
+         grab_mouse (si, ssi->screensaver_window,
+                     (si->demoing_p
+                      ? 0
+                      : ssi->cursor));
          XUngrabServer (si->dpy);
          XSync (si->dpy, False);               /* ###### (danger over) */
        }
index d5d3ba9c93b4c912a847e95f5fdeeb39035a3771..b11f203e6edab19864bd68bff5a8df3df1fe7710 100644 (file)
@@ -10,8 +10,6 @@
  * implied warranty.
  */
 
-#define STANDALONE
-
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
 
 #include <X11/Intrinsic.h>     /* only needed to get through xscreensaver.h */
 
+#include "remote.h"
 #include "version.h"
 
-#ifdef STANDALONE
-  static char *progname;
-  static Atom XA_VROOT;
-  static Atom XA_SCREENSAVER, XA_SCREENSAVER_RESPONSE, XA_SCREENSAVER_VERSION;
-  static Atom XA_SCREENSAVER_TIME, XA_SELECT;
-#else  /* !STANDALONE */
-# include "xscreensaver.h"
-#endif /* !STANDALONE */
-
-
 #ifdef _VROOT_H_
 ERROR! you must not include vroot.h in this file
 #endif
 
+char *progname;
 
+Atom XA_VROOT;
+Atom XA_SCREENSAVER, XA_SCREENSAVER_VERSION, XA_SCREENSAVER_RESPONSE;
+Atom XA_SCREENSAVER_ID, XA_SCREENSAVER_TIME, XA_SELECT, XA_DEMO;
+static Atom XA_ACTIVATE, XA_DEACTIVATE, XA_CYCLE, XA_NEXT, XA_PREV, XA_EXIT;
+static Atom XA_RESTART, XA_PREFS, XA_LOCK;
 
-static Window
-find_screensaver_window (Display *dpy, char **version)
-{
-  int i;
-  Window root = RootWindowOfScreen (DefaultScreenOfDisplay (dpy));
-  Window root2, parent, *kids;
-  unsigned int nkids;
-
-  if (version) *version = 0;
-
-  if (! XQueryTree (dpy, root, &root2, &parent, &kids, &nkids))
-    abort ();
-  if (root != root2)
-    abort ();
-  if (parent)
-    abort ();
-  if (! (kids && nkids))
-    abort ();
-  for (i = 0; i < nkids; i++)
-    {
-      Atom type;
-      int format;
-      unsigned long nitems, bytesafter;
-      char *v;
-
-      if (XGetWindowProperty (dpy, kids[i],
-                             XA_SCREENSAVER_VERSION,
-                             0, 200, False, XA_STRING,
-                             &type, &format, &nitems, &bytesafter,
-                             (unsigned char **) &v)
-         == Success
-         && type != None)
-       {
-         if (version)
-           *version = v;
-         return kids[i];
-       }
-    }
-  fprintf (stderr, "%s: no screensaver is running on display %s\n", progname,
-          DisplayString (dpy));
-  return 0;
-}
-
-
-static int
-send_xscreensaver_command (Display *dpy, Atom command, long argument,
-                          Window *window_ret)
-{
-  char *v = 0;
-  Window window = find_screensaver_window (dpy, &v);
-  XWindowAttributes xgwa;
-
-  if (window_ret)
-    *window_ret = window;
-
-  if (!window)
-    return -1;
-
-  /* Select for property change events, so that we can read the response. */
-  XGetWindowAttributes (dpy, window, &xgwa);
-  XSelectInput (dpy, window, xgwa.your_event_mask | PropertyChangeMask);
-
-  if (command == XA_SCREENSAVER_TIME ||
-      command == XA_SCREENSAVER_VERSION)
-    {
-      XClassHint hint;
-      memset (&hint, 0, sizeof(hint));
-      if (!v || !*v)
-       {
-         fprintf (stderr, "%s: version property not set on window 0x%x?\n",
-                  progname, (unsigned int) window);
-         return -1;
-       }
-
-      XGetClassHint(dpy, window, &hint);
-      if (!hint.res_class)
-       {
-         fprintf (stderr, "%s: class hints not set on window 0x%x?\n",
-                  progname, (unsigned int) window);
-         return -1;
-       }
-
-      fprintf (stdout, "%s %s", hint.res_class, v);
-
-      if (command != XA_SCREENSAVER_TIME)
-       {
-         fprintf (stdout, "\n");
-       }
-      else
-       {
-         Atom type;
-         int format;
-         unsigned long nitems, bytesafter;
-         unsigned char *data = 0;
-         Bool active_p = False;
-
-         if (XGetWindowProperty (dpy, window, XA_VROOT,
-                                 0, 0, False, XA_WINDOW,
-                                 &type, &format, &nitems, &bytesafter,
-                                 &data)
-             == Success
-             && type != None)
-           active_p = True;
-
-         if (data) free (data);
-         data = 0;
-
-         if (XGetWindowProperty (dpy, window,
-                                 XA_SCREENSAVER_TIME,
-                                 0, 1, False, XA_INTEGER,
-                                 &type, &format, &nitems, &bytesafter,
-                                 &data)
-             == Success
-             && type == XA_INTEGER
-             && data)
-           {
-             CARD32 time32 = *((CARD32 *)data);
-             time_t tt = (time_t) time32;
-
-             if (active_p)
-               fprintf (stdout, ": screen blanked since ");
-             else
-               /* suggestions for a better way to phrase this are welcome. */
-               fprintf (stdout, ": screen non-blanked since ");
-             fprintf (stdout, "%s", ctime(&tt));
-             if (data) free (data);
-           }
-         else
-           {
-             if (data) free (data);
-             fprintf (stdout, "\n");
-             fflush (stdout);
-             fprintf (stderr, "%s: no time on window 0x%x (%s %s).\n",
-                      progname, (unsigned int) window,
-                      hint.res_class, (v ? v : "???"));
-             return -1;
-           }
-       }
-
-      /* No need to read a response for these commands. */
-      return 1;
-    }
-  else
-    {
-      XEvent event;
-      long arg1 = (command == XA_SELECT ? argument : 0L);
-      event.xany.type = ClientMessage;
-      event.xclient.display = dpy;
-      event.xclient.window = window;
-      event.xclient.message_type = XA_SCREENSAVER;
-      event.xclient.format = 32;
-      memset (&event.xclient.data, 0, sizeof(event.xclient.data));
-      event.xclient.data.l[0] = (long) command;
-      event.xclient.data.l[1] = arg1;
-      if (! XSendEvent (dpy, window, False, 0L, &event))
-       {
-         fprintf (stderr, "%s: XSendEvent(dpy, 0x%x ...) failed.\n",
-                  progname, (unsigned int) window);
-         return -1;
-       }
-    }
-  XSync (dpy, 0);
-  return 0;
-}
-
-
-static XErrorHandler old_handler = 0;
-static Bool got_badwindow = False;
-static int
-BadWindow_ehandler (Display *dpy, XErrorEvent *error)
-{
-  /* When we notice a window being created, we spawn a timer that waits
-     30 seconds or so, and then selects events on that window.  This error
-     handler is used so that we can cope with the fact that the window
-     may have been destroyed <30 seconds after it was created.
-   */
-  if (error->error_code == BadWindow)
-    {
-      got_badwindow = True;
-      return 0;
-    }
-  else
-    {
-      fprintf (stderr, "%s: ", progname);
-      return (*old_handler) (dpy, error);
-    }
-}
-
-
-static int
-xscreensaver_command_response (Display *dpy, Window window)
-{
-  int fd = ConnectionNumber (dpy);
-  int timeout = 10;
-  int status;
-  fd_set fds;
-  struct timeval tv;
-
-  while (1)
-    {
-      FD_ZERO(&fds);
-      FD_SET(fd, &fds);
-      memset(&tv, 0, sizeof(tv));
-      tv.tv_sec = timeout;
-      status = select (fd+1, &fds, 0, &fds, &tv);
-
-      if (status < 0)
-       {
-         char buf[1024];
-         sprintf (buf, "%s: waiting for reply", progname);
-         perror (buf);
-         return status;
-       }
-      else if (status == 0)
-       {
-         fprintf (stderr, "%s: no response to command.\n", progname);
-         return -1;
-       }
-      else
-       {
-         XEvent event;
-         XNextEvent (dpy, &event);
-         switch (event.xany.type) {
-         case PropertyNotify:
-           if (event.xproperty.state == PropertyNewValue &&
-               event.xproperty.atom == XA_SCREENSAVER_RESPONSE)
-             {
-               Status st2;
-               Atom type;
-               int format;
-               unsigned long nitems, bytesafter;
-               char *msg = 0;
-
-               old_handler = XSetErrorHandler (BadWindow_ehandler);
-               XSync (dpy, False);
-
-               st2 = XGetWindowProperty (dpy, window,
-                                         XA_SCREENSAVER_RESPONSE,
-                                         0, 1024, True,
-                                         AnyPropertyType,
-                                         &type, &format, &nitems, &bytesafter,
-                                         (unsigned char **) &msg);
-
-               if (got_badwindow)
-                 {
-                   fprintf (stdout,
-                            "%s: xscreensaver window has been deleted.\n",
-                            progname);
-                   return 0;
-                 }
-
-               if (st2 == Success && type != None)
-                 {
-                   if (type != XA_STRING || format != 8)
-                     {
-                       fprintf (stderr,
-                                "%s: unrecognized response property.\n",
-                                progname);
-                       if (msg) XFree (msg);
-                       return -1;
-                     }
-                   else if (!msg || (msg[0] != '+' && msg[0] != '-'))
-                     {
-                       fprintf (stderr,
-                                "%s: unrecognized response message.\n",
-                                progname);
-                       if (msg) XFree (msg);
-                       return -1;
-                     }
-                   else
-                     {
-                       int ret = (msg[0] == '+' ? 0 : -1);
-                       fprintf ((ret < 0 ? stderr : stdout),
-                                "%s: %s\n",
-                                progname,
-                                msg+1);
-                       XFree (msg);
-                       return ret;
-                     }
-                 }
-             }
-           break;
-
-         default:
-           fprintf (stderr, "%s: got unexpected response event %d.\n",
-                    progname, event.xany.type);
-           return -1;
-           break;
-         }
-       }
-    }
-}
-
-
-int
-xscreensaver_command (Display *dpy, Atom command, long argument)
-{
-  Window w = 0;
-  int status = send_xscreensaver_command (dpy, command, argument, &w);
-  if (status == 0)
-    status = xscreensaver_command_response (dpy, w);
-  fflush (stdout);
-  fflush (stderr);
-  return status;
-}
-
-\f
-#ifdef STANDALONE
-static Atom XA_ACTIVATE, XA_DEACTIVATE, XA_CYCLE, XA_NEXT, XA_PREV;
-static Atom XA_EXIT, XA_RESTART, XA_DEMO, XA_PREFS, XA_LOCK;
-
-static char *progname;
 static char *screensaver_version;
 static char *usage = "\n\
 usage: %s -<option>\n\
@@ -434,8 +117,9 @@ usage: %s -<option>\n\
   For updates, check http://www.jwz.org/xscreensaver/\n\
 \n";
 
-#define USAGE() \
- { fprintf (stderr, usage, progname, screensaver_version); exit (1); }
+#define USAGE() do { \
+ fprintf (stderr, usage, progname, screensaver_version); exit (1); \
+ } while(0)
 
 int
 main (int argc, char **argv)
@@ -459,7 +143,7 @@ main (int argc, char **argv)
       L = strlen (s);
       if (L < 2) USAGE ();
       if (!strncmp (s, "-display", L))         dpyname = argv [++i];
-      else if (cmd) USAGE ()
+      else if (cmd) USAGE();
       else if (!strncmp (s, "-activate", L))   cmd = &XA_ACTIVATE;
       else if (!strncmp (s, "-deactivate", L)) cmd = &XA_DEACTIVATE;
       else if (!strncmp (s, "-cycle", L))      cmd = &XA_CYCLE;
@@ -476,18 +160,76 @@ main (int argc, char **argv)
       else if (!strncmp (s, "-time", L))       cmd = &XA_SCREENSAVER_TIME;
       else USAGE ();
 
-      if (cmd == &XA_SELECT)
+      if (cmd == &XA_SELECT || cmd == &XA_DEMO)
        {
-         char junk;
-         i++;
-         if (i >= argc ||
-             (1 != sscanf(argv[i], " %ld %c", &arg, &junk)))
-           USAGE ();
+         long a;
+         char c;
+         if (i+1 < argc && (1 == sscanf(argv[i+1], " %ld %c", &a, &c)))
+           {
+             arg = a;
+             i++;
+           }
        }
     }
+
   if (!cmd)
     USAGE ();
 
+  if (arg < 0)
+    /* no command may have a negative argument. */
+    USAGE();
+  else if (arg == 0)
+    {
+      /* SELECT must have a non-zero argument. */
+      if (cmd == &XA_SELECT)
+       USAGE();
+    }
+  else /* arg > 0 */
+    {
+      /* no command other than SELECT and DEMO may have a non-zero argument. */
+      if (cmd != &XA_DEMO && cmd != &XA_SELECT)
+       USAGE();
+    }
+
+
+
+  /* For backward compatibility: -demo with no arguments used to send a
+     "DEMO 0" ClientMessage to the xscreensaver process, which brought up
+     the built-in demo mode dialog.  Now that the demo mode dialog is no
+     longer built in, we bring it up by just running the "xscreensaver-demo"
+     program.
+
+     Note that "-DEMO <n>" still sends a ClientMessage.
+   */
+  if (cmd == &XA_PREFS ||
+      (cmd == &XA_DEMO && arg == 0))
+    {
+      char buf [512];
+      char *new_argv[] = { "xscreensaver-demo", 0, 0, 0, 0, 0 };
+      int ac = 1;
+
+      if (dpyname)
+       {
+         new_argv[ac++] = "-display";
+         new_argv[ac++] = dpyname;
+       }
+
+      if (cmd == &XA_PREFS)
+       new_argv[ac++] = "-prefs";
+
+      fflush(stdout);
+      fflush(stderr);
+      execvp (new_argv[0], new_argv);  /* shouldn't return */
+
+      sprintf (buf, "%s: could not exec %s", progname, new_argv[0]);
+      perror(buf);
+      fflush(stdout);
+      fflush(stderr);
+      exit (-1);
+    }
+
+
+
   if (!dpyname) dpyname = (char *) getenv ("DISPLAY");
   dpy = XOpenDisplay (dpyname);
   if (!dpy)
@@ -499,6 +241,7 @@ main (int argc, char **argv)
 
   XA_VROOT = XInternAtom (dpy, "__SWM_VROOT", False);
   XA_SCREENSAVER = XInternAtom (dpy, "SCREENSAVER", False);
+  XA_SCREENSAVER_ID = XInternAtom (dpy, "_SCREENSAVER_ID", False);
   XA_SCREENSAVER_VERSION = XInternAtom (dpy, "_SCREENSAVER_VERSION",False);
   XA_SCREENSAVER_TIME = XInternAtom (dpy, "_SCREENSAVER_TIME", False);
   XA_SCREENSAVER_RESPONSE = XInternAtom (dpy, "_SCREENSAVER_RESPONSE", False);
@@ -522,9 +265,7 @@ main (int argc, char **argv)
        so if we're issuing an activation command, wait a second. */
     sleep (1);
 
-  i = xscreensaver_command (dpy, *cmd, arg);
+  i = xscreensaver_command (dpy, *cmd, arg, True);
   if (i < 0) exit (i);
   else exit (0);
 }
-
-#endif /* STANDALONE */
index a3a92fa3fecc69fd53ef94290a5979a4ee528cc7..7be17e5230c2ce4fe1fab439a5cc66c7a8555d55 100644 (file)
@@ -11,7 +11,7 @@
 .if n .sp 1
 .if t .sp .5
 ..
-.TH XScreenSaver 1 "08-Oct-98 (2.34)" "X Version 11"
+.TH XScreenSaver 1 "24-Oct-98 (3.01)" "X Version 11"
 .SH NAME
 xscreensaver-command - control a running xscreensaver process
 .SH SYNOPSIS
@@ -36,8 +36,13 @@ process by sending it client-messages.
 
 .BR xscreensaver (1)
 has a client-server model: the xscreensaver process is a
-daemon that runs in the background; it is controlled by the 
-foreground \fIxscreensaver-command\fP program.
+daemon that runs in the background; it is controlled by other
+foreground programs such as \fIxscreensaver-command\fP and
+.BR xscreensaver\-demo (1).
+
+This program, \fIxscreensaver-command\fP, is a command-line-oriented tool; the 
+.BR xscreensaver\-demo (1).
+program is a graphical tool.
 .SH OPTIONS
 .I xscreensaver-command
 accepts the following command-line options:
@@ -46,17 +51,24 @@ accepts the following command-line options:
 Prints a brief summary of command-line options.
 .TP 8
 .B \-demo
-Cause the screensaver to enter its interactive demo mode, in which one
-can experiment with the various graphics hacks available.  See
+This just launches the
+.BR xscreensaver\-demo (1)
+program, in which one can experiment with the various graphics hacks
+available, and edit parameters.
+.TP 8
+.B \-demo \fP\fInumber\fP
+When the \fI\-demo\fP option is followed by an integer, it instructs 
+the \fIxscreensaver\fP daemon to run that hack, and wait for the user
+to click the mouse before deactivating (i.e., mouse motion does not
+deactivate.)  This is the mechanism by which
+.BR xscreensaver\-demo (1)
+communicates with the
 .BR xscreensaver (1)
-for details.
+daemon.  (The first hack in the list is numbered 1, not 0.)
 .TP 8
 .B \-prefs
-Cause the screensaver to enter its interactive demo mode, and bring up
-the Preferences control panel, in which one can change most of the settings
-that control the xscreensaver daemon's behavior.  See
-.BR xscreensaver (1)
-for details.
+Like the no-argument form of \fI\-demo\fP, but brings up that program's
+Preferences panel by default.
 .TP 8
 .B \-activate
 Tell xscreensaver to turn on immediately (that is, blank the screen, as if
@@ -67,7 +79,7 @@ It is useful to run this from a menu; you may wish to run it as
 .EX
 sleep 5 ; xscreensaver-command -activate
 .EE
-to be sure that you have time to remove your hand from the mouse before
+to be sure that you have time to take your hand off the mouse before
 the screensaver comes on.  (Because if you jiggle the mouse, xscreensaver
 will notice, and deactivate.)
 .TP 8
@@ -110,21 +122,16 @@ active.  If you are using a virtual root window manager, that can leave
 things in an inconsistent state, and you may need to restart your window
 manager to repair the damage.
 .TP 8
-.B \-restart
-Causes the screensaver process to exit and then restart with the same command
-line arguments as last time.  Do this after you've changed the resource
-database, to cause xscreensaver to notice the changes.
-
-If the screensaver is run from \fIxdm(1)\fP (that is, it is already running
-before you log in) then you may want to issue the \fI\-restart\fP command from
-one of your startup scripts, so that the screensaver gets your resource
-settings instead of the default ones.
-.TP 8
 .B \-lock
 Tells the running xscreensaver process to lock the screen immediately.  
 This is like \fI\-activate\fP, but forces locking as well, even if locking
 is not the default (that is, even if xscreensaver's \fIlock\fP resource is
 false, and even if the \fIlockTimeout\fP resource is non-zero.)
+
+Note that locking doesn't work unless the \fIxscreensaver\fP process is
+running as you.  See 
+.BR xscreensaver (1)
+for details.
 .TP 8
 .B \-version
 Prints the version of xscreensaver that is currently running on the display:
@@ -138,6 +145,21 @@ Prints the time at which the screensaver last activated or
 deactivated (roughly, how long the user has been idle or non-idle: but 
 not quite, since it only tells you when the screen became blanked or
 un-blanked.)
+.TP 8
+.B \-restart
+Causes the screensaver process to exit and then restart with the same command
+line arguments as last time.  Do this after you've changed the resource
+database, to cause xscreensaver to notice the changes.
+
+.B Warning:
+if you have a \fI.xscreensaver\fP file, this might not do what you 
+expect.  You're probably better off killing the existing 
+xscreensaver (with \fIxscreensaver\-command -exit\fP) and then
+launching it again.
+
+The important point is, you need to make sure that the xscreensaver 
+process is running as you.  If it's not, it won't be reading the 
+right \fI.xscreensaver\fP file.
 .SH DIAGNOSTICS
 If an error occurs while communicating with the \fIxscreensaver\fP daemon, or
 if the daemon reports an error, a diagnostic message will be printed to
@@ -158,11 +180,11 @@ the \fIxscreensaver\fP process, not the \fIxscreensaver-command\fP process.
 .SH UPGRADES
 The latest version of
 .BR xscreensaver (1)
-and \fIxscreensaver\-command\fP can always be found at 
-http://www.jwz.org/xscreensaver/
+and related tools can always be found at http://www.jwz.org/xscreensaver/
 .SH "SEE ALSO"
 .BR X (1),
 .BR xscreensaver (1)
+.BR xscreensaver\-demo (1)
 .SH COPYRIGHT
 Copyright \(co 1992, 1993, 1997, 1998
 by Jamie Zawinski.  Permission to use, copy, modify, distribute, and sell
diff --git a/driver/xscreensaver-demo.man b/driver/xscreensaver-demo.man
new file mode 100644 (file)
index 0000000..5785582
--- /dev/null
@@ -0,0 +1,210 @@
+.de EX         \"Begin example
+.ne 5
+.if n .sp 1
+.if t .sp .5
+.nf
+.in +.5i
+..
+.de EE
+.fi
+.in -.5i
+.if n .sp 1
+.if t .sp .5
+..
+.TH XScreenSaver 1 "24-Oct-98 (3.01)" "X Version 11"
+.SH NAME
+xscreensaver-demo - interactively control the background xscreensaver daemon
+.SH SYNOPSIS
+.B xscreensaver\-demo
+[\-display \fIhost:display.screen\fP] [\-prefs] [\-xrm \fIresources\fP]
+.SH DESCRIPTION
+The \fIxscreensaver\-demo\fP program is a graphical front-end for 
+setting the parameters used by the background
+.BR xscreensaver (1)
+daemon.
+It is essentially two things: a tool for editing the \fI~/.xscreensaver\fP
+file; and a tool for demoing the various graphics hacks that 
+the \fIxscreensaver\fP daemon will launch.
+
+The main dialog box contains a scrolling list, a text field, and a number 
+of buttons.  
+
+Double-clicking on one of the programs in the list will run it.  The screen
+will go black, and the program will run in full-screen mode, just as it would
+if the \fIxscreensaver\fP daemon had launched it.  Clicking the mouse again
+will stop the demo and un-blank the screen, making the dialog box visible 
+again.
+
+Single-clicking in the list will place the indicated program and its args
+in the text field to be edited.  Edit the arguments and hit return to run
+the program with the parameters you have specified.  This will also save
+your changes to your \fI~/.xscreensaver\fP file: so any changes you make
+in this way are persistent.
+
+If one of the lines in the scrolling list begins with the character "-",
+then that means that the program is disabled: \fIxscreensaver\fP will not
+select it to be run (though you can still try it out by clicking on it.)
+Rather than just deleting the programs you don't want to run, you might
+want to disable them in this way instead, so that you can more easily change
+your mind later.
+
+If the line begins with the name of a visual, followed by a colon, then
+that program will only be run on that kind of visual.  For example, you can
+specify that a particular program should only be run if color is available,
+and another should only be run in monochrome.  See the discussion of 
+the \fIprograms\fP parameter in the \fIConfiguration\fP section of the
+.BR xscreensaver (1)
+manual.
+
+The buttons are:
+.TP 8
+.B Run Next
+Clicking this button will run the next program in the list after the 
+currently-selected one, and will wrap around to the top when it reaches
+the bottom.
+.TP 8
+.B Run Previous
+Opposite of Run Next; at the top, it wraps around to the bottom.
+.TP 8
+.B Preferences
+This pops up a second dialog box, in which you have the option to 
+interactively change most of the screensaver's operational parameters,
+such as its timeouts, and whether it should lock the screen.  When you
+click OK, your chosen settings will take effect immediately, and will
+also be saved to the \fI~/.xscreensaver\fP file in your home directory,
+so that the settings will persist next time.
+.TP 8
+.B Quit
+Exits the \fIxscreensaver-demo\fP program.  The background \fIxscreensaver\fP
+daemon will continue running as before.
+.BR xscreensaver\-command (1).
+
+.P
+The Preferences dialog box lets you change the following settings.
+
+(There are more settings available, but these are the most commonly used
+ones; see the manual for
+.BR xscreensaver (1)
+for other parameters that can be set by editing the \fI~/.xscreensaver\fP
+file, or the X resource database.)
+.TP 8
+.B Saver Timeout
+After the user has been idle this long, the \fIxscreensaver\fP daemon
+will blank the screen.
+.TP 8
+.B Cycle Timeout
+After the screensaver has been running for this long, the currently
+running graphics demo will be killed, and a new one started.  
+If this is 0, then the graphics demo will never be changed:
+only one demo will run until the screensaver is deactivated by user 
+activity.
+.TP 8
+.B Verbose\ 
+Whether to print lots of debugging information.
+.TP 8
+.B Install Colormap
+Whether to install a private colormap while the screensaver is active, so
+that the graphics hacks can get as many colors as possible.  (This only
+applies when the screen's default visual is being used, since non-default
+visuals get their own colormaps automatically.)  This can also be overridden
+on a per-demo basis.
+.TP 8
+.B Fade Colormap
+If selected, then when the screensaver activates, the current contents
+of the screen will fade to black instead of simply winking out.  This only
+works on displays with writable colormaps, that is, if the screen's default
+visual is a PseudoColor visual.  A fade will also be done when
+switching graphics hacks (when the \fICycle Timeout\fP expires.)
+.TP 8
+.B Unfade Colormap
+The complement to \fIFade Colormap\fP: if selected, then when the screensaver
+deactivates, the original contents of the screen will fade in from black
+instead of appearing immediately.  This only works on displays with writable
+colormaps, and when \fIFade Colormap\fP is also selected.
+.TP 8
+.B Fade Duration
+When fading or unfading are selected, this controls how long the fade will
+take.
+.TP 8
+.B Fade Ticks
+This controls how many times a second the colormap will be changed to 
+effect a fade.  Higher numbers yield smoother fades, but may make the
+fades take longer than the specified number of seconds, if your server
+isn't fast enough to keep up.
+.TP 8
+.B Require Password
+Whether the screen saver should lock the screen when it activates.
+.TP 8
+.B Lock Timeout
+If \fIRequire Password\fP is selected, this controls the length of 
+the ``grace period'' between when the screensaver activates, and when the
+screen becomes locked.  For example, if this is 0:05:00, 
+and \fISaver Timeout\fP is 0:10:00, then after 10 minutes, the screen 
+would blank.  If there was user  activity at 12 minutes, no password
+would be required to un-blank the screen.  But, if there was user activity
+at 15 minutes or later (that is, \fILock Timeout\fP minutes after 
+activation) then a password would be required.  The default is 0, meaning
+that if locking is enabled, then a password will be required as soon as the 
+screen blanks.
+.TP 8
+.B Password Timeout
+When the screensaver is prompting for a password, the prompt dialog box will
+stay on the screen for this long before giving up, and reverting to 
+screen-saving mode.
+.SH COMMAND-LINE OPTIONS
+.I xscreensaver\-demo
+accepts the following command line options.
+.TP 8
+.B \-display \fIhost:display.screen\fP
+The X display to use.  The \fIxscreensaver\-demo\fP program will control
+the \fIxscreensaver\fP daemon that is running on that same display.
+
+It's important that the \fIxscreensaver\fP and \fIxscreensaver\-demo\fP
+processes be running on the same machine, or at least, on two machines
+that share a file system: when \fIxscreensaver\-demo\fP writes a new version
+of the \fI~/.xscreensaver\fP file, it's important that the \fIxscreensaver\fP
+see that same file.  If the two processes are seeing 
+different \fI~/.xscreensaver\fP files, things will malfunction.
+.TP 8
+.B \-prefs
+Start up in Preferences mode: this is just like launching the program with
+no arguments, and then pressing the \fIPreferences\fP button.
+.SH ENVIRONMENT
+.PP
+.TP 8
+.B DISPLAY
+to get the default host and display number.  See the comments about 
+the \fI\-display\fP command-line option above.
+.TP 8
+.B PATH
+to find the sub-programs to run.  However, note that the sub-programs 
+are actually launched by the \fIxscreensaver\fP daemon, not 
+by \fIxscreensaver-demo\fP itself.  So, what matters is what \fB$PATH\fP
+the \fIxscreensaver\fP program sees.
+.TP 8
+.B HOME
+for the directory in which to read and write the \fI.xscreensaver\fP file.
+.TP 8
+.B XENVIRONMENT
+to get the name of a resource file that overrides the global resources
+stored in the RESOURCE_MANAGER property.
+.SH UPGRADES
+The latest version can always be found at 
+http://www.jwz.org/xscreensaver/
+.SH SEE ALSO
+.BR X (1),
+.BR xscreensaver (1),
+.BR xscreensaver\-command (1)
+.SH COPYRIGHT
+Copyright \(co 1992, 1993, 1997, 1998
+by 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 the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in supporting
+documentation.  No representations are made about the suitability of this
+software for any purpose.  It is provided "as is" without express or implied
+warranty.
+.SH AUTHOR
+Jamie Zawinski <jwz@jwz.org>, 13-aug-92.
+
+Please let me know if you find any bugs or make any improvements.
index 92b0f6f4a35a1e08419c6cee7497ce7f96d1ee57..d0efd9b0359f7942e5c2bef28f37c4e81c8c0ba8 100644 (file)
@@ -169,6 +169,7 @@ static XrmOptionDescRec options [] = {
   { "-cycle",             ".cycle",            XrmoptionSepArg, 0 },
   { "-lock-mode",         ".lock",             XrmoptionNoArg, "on" },
   { "-no-lock-mode",      ".lock",             XrmoptionNoArg, "off" },
+  { "-no-lock",                   ".lock",             XrmoptionNoArg, "off" },
   { "-lock-timeout",      ".lockTimeout",      XrmoptionSepArg, 0 },
   { "-lock-vts",          ".lockVTs",          XrmoptionNoArg, "on" },
   { "-no-lock-vts",       ".lockVTs",          XrmoptionNoArg, "off" },
@@ -228,7 +229,8 @@ The standard Xt command-line options are accepted; other options include:\n\
 See the manual for other options and X resources.\n\
 \n\
 The `xscreensaver' program should be left running in the background.\n\
-Use the `xscreensaver-command' program to manipulate a running xscreensaver.\n\
+Use the `xscreensaver-demo' and `xscreensaver-command' programs to\n\
+manipulate a running xscreensaver.\n\
 \n\
 The `*programs' resource controls which graphics demos will be launched by\n\
 the screensaver.  See `man xscreensaver' or the web page for more details.\n\
@@ -236,7 +238,7 @@ the screensaver.  See `man xscreensaver' or the web page for more details.\n\
 Just getting started?  Try this:\n\
 \n\
         xscreensaver &\n\
-        xscreensaver-command -demo\n\
+        xscreensaver-demo\n\
 \n\
 For updates, check http://www.jwz.org/xscreensaver/\n\
 \n",
@@ -318,10 +320,6 @@ saver_ehandler (Display *dpy, XErrorEvent *error)
 /* The zillions of initializations.
  */
 
-static void get_screenhacks (saver_info *si);
-
-
-
 /* Set progname, version, etc.  This is done very early.
  */
 static void
@@ -388,13 +386,13 @@ connect_to_server (saver_info *si, int *argc, char **argv)
                                    argc, argv, defaults, 0, 0);
 
   si->dpy = XtDisplay (toplevel_shell);
-  si->db = XtDatabase (si->dpy);
+  si->prefs.db = XtDatabase (si->dpy);
   XtGetApplicationNameAndClass (si->dpy, &progname, &progclass);
 
   if(strlen(progname) > 100)   /* keep it short. */
     progname [99] = 0;
 
-  db = si->db; /* resources.c needs this */
+  db = si->prefs.db;   /* resources.c needs this */
 
   XA_VROOT = XInternAtom (si->dpy, "__SWM_VROOT", False);
   XA_SCREENSAVER = XInternAtom (si->dpy, "SCREENSAVER", False);
@@ -433,11 +431,6 @@ process_command_line (saver_info *si, int *argc, char **argv)
        /* no resource for this one, out of paranoia. */
        si->prefs.debug_p = True;
 
-      else if (!strcmp (argv[i], "-initial-demo-mode"))
-       /* This isn't an advertized option; it is used internally to implement
-          the "Reinitialize" button on the Demo Mode window. */
-       si->demo_mode_p = True;
-
       else if (!strcmp (argv[i], "-h") ||
               !strcmp (argv[i], "-help") ||
               !strcmp (argv[i], "--help"))
@@ -464,13 +457,20 @@ process_command_line (saver_info *si, int *argc, char **argv)
              !strcmp (s, "-version") ||
              !strcmp (s, "-time"))
            {
-             fprintf (stderr, "\n\
-    However, %s is an option to the `xscreensaver-command' program.\n\
+
+             if (!strcmp (s, "-demo") || !strcmp (s, "-prefs"))
+               fprintf (stderr, "\n\
+    Perhaps you meant to run the `xscreensaver-demo' program instead?\n");
+             else
+               fprintf (stderr, "\n\
+    However, `%s' is an option to the `xscreensaver-command' program.\n", s);
+
+             fprintf (stderr, "\
     The `xscreensaver' program is a daemon that runs in the background.\n\
     You control a running xscreensaver process by sending it messages\n\
-    with `xscreensaver-command'.  See the man pages for details,\n\
-    or check the web page: http://www.jwz.org/xscreensaver/\n\n",
-                      s);
+    with `xscreensaver-demo' or `xscreensaver-command'.\n\
+.   See the man pages for details, or check the web page:\n\
+    http://www.jwz.org/xscreensaver/\n\n");
 
              /* Since version 1.21 renamed the "-lock" option to "-lock-mode",
                 suggest that explicitly. */
@@ -479,6 +479,7 @@ process_command_line (saver_info *si, int *argc, char **argv)
     Or perhaps you meant either the \"-lock-mode\" or the\n\
     \"-lock-timeout <minutes>\" options to xscreensaver?\n\n");
            }
+
          exit (1);
        }
     }
@@ -504,9 +505,9 @@ print_banner (saver_info *si)
 
   if (p->verbose_p)
     fprintf (stderr,
-            "%s %s, copyright (c) 1991-1998 by Jamie Zawinski <jwz@jwz.org>\n"
-            " pid = %d.\n",
-            blurb(), si->version, (int) getpid ());
+            "%s %s, copyright (c) 1991-1998 "
+            "by Jamie Zawinski <jwz@jwz.org>.\n",
+            progname, si->version);
 
   if (p->debug_p)
     fprintf (stderr, "\n"
@@ -533,6 +534,9 @@ print_banner (saver_info *si)
                     blurb(), si->orig_uid);
          fprintf (stderr, "%s: %s\n", blurb(), si->uid_message);
        }
+
+      fprintf (stderr, "%s: in process %lu.\n", blurb(),
+              (unsigned long) getpid());
     }
 
   /* If locking was not able to be initalized for some reason, explain why.
@@ -613,138 +617,7 @@ initialize_per_screen_info (saver_info *si, Widget toplevel_shell)
        }
     }
 
-  si->fading_possible_p = found_any_writable_cells;
-}
-
-
-/* Populate `saver_preferences' with the contents of the resource database.
-   Note that this may be called multiple times -- it is re-run each time
-   the ~/.xscreensaver file is reloaded.
-
-   This function can be very noisy, since it issues resource syntax errors
-   and so on.
- */
-void
-get_resources (saver_info *si)
-{
-  char *s;
-  saver_preferences *p = &si->prefs;
-
-  if (si->init_file_date == 0)
-    /* The date will be 0 the first time this is called; and when this is
-       called subsequent times, the file will have already been reloaded. */
-    read_init_file (si);
-
-  p->xsync_p       = get_boolean_resource ("synchronous", "Synchronous");
-  if (p->xsync_p)
-    XSynchronize(si->dpy, True);
-
-  p->verbose_p     = get_boolean_resource ("verbose", "Boolean");
-  p->timestamp_p    = get_boolean_resource ("timestamp", "Boolean");
-  p->lock_p        = get_boolean_resource ("lock", "Boolean");
-  p->lock_vt_p     = get_boolean_resource ("lockVTs", "Boolean");
-  p->fade_p        = get_boolean_resource ("fade", "Boolean");
-  p->unfade_p      = get_boolean_resource ("unfade", "Boolean");
-  p->fade_seconds   = 1000 * get_seconds_resource ("fadeSeconds", "Time");
-  p->fade_ticks            = get_integer_resource ("fadeTicks", "Integer");
-  p->install_cmap_p = get_boolean_resource ("installColormap", "Boolean");
-  p->nice_inferior  = get_integer_resource ("nice", "Nice");
-
-  p->initial_delay   = 1000 * get_seconds_resource ("initialDelay", "Time");
-  p->splash_duration = 1000 * get_seconds_resource ("splashDuration", "Time");
-  p->timeout         = 1000 * get_minutes_resource ("timeout", "Time");
-  p->lock_timeout    = 1000 * get_minutes_resource ("lockTimeout", "Time");
-  p->cycle           = 1000 * get_minutes_resource ("cycle", "Time");
-  p->passwd_timeout  = 1000 * get_seconds_resource ("passwdTimeout", "Time");
-  p->pointer_timeout = 1000 * get_seconds_resource ("pointerPollTime", "Time");
-  p->notice_events_timeout = 1000*get_seconds_resource("windowCreationTimeout",
-                                                      "Time");
-  p->shell = get_string_resource ("bourneShell", "BourneShell");
-
-  p->help_url = get_string_resource("helpURL", "URL");
-  p->load_url_command = get_string_resource("loadURL", "LoadURL");
-
-  if ((s = get_string_resource ("splash", "Boolean")))
-    if (!get_boolean_resource("splash", "Boolean"))
-      p->splash_duration = 0;
-  if (s) free (s);
-
-  if (p->verbose_p && !si->fading_possible_p && (p->fade_p || p->unfade_p))
-    {
-      fprintf (stderr,
-              (si->nscreens == 1
-               ? "%s: the screen has no PseudoColor or GrayScale visuals.\n"
-               : "%s: no screens have PseudoColor or GrayScale visuals.\n"),
-              blurb());
-      fprintf (stderr, "%s: ignoring the request for fading/unfading.\n",
-              blurb());
-    }
-
-  /* don't set use_xidle_extension unless it is explicitly specified */
-  if ((s = get_string_resource ("xidleExtension", "Boolean")))
-    p->use_xidle_extension = get_boolean_resource ("xidleExtension","Boolean");
-  else
-#ifdef HAVE_XIDLE_EXTENSION            /* pick a default */
-    p->use_xidle_extension = True;     /* if we have it, use it */
-#else  /* !HAVE_XIDLE_EXTENSION */
-    p->use_xidle_extension = False;
-#endif /* !HAVE_XIDLE_EXTENSION */
-  if (s) free (s);
-
-  /* don't set use_mit_extension unless it is explicitly specified */
-  if ((s = get_string_resource ("mitSaverExtension", "Boolean")))
-    p->use_mit_saver_extension = get_boolean_resource ("mitSaverExtension",
-                                                      "Boolean");
-  else
-#ifdef HAVE_MIT_SAVER_EXTENSION                /* pick a default */
-    p->use_mit_saver_extension = False;        /* Default false, because it sucks */
-#else  /* !HAVE_MIT_SAVER_EXTENSION */
-    p->use_mit_saver_extension = False;
-#endif /* !HAVE_MIT_SAVER_EXTENSION */
-  if (s) free (s);
-
-
-  /* don't set use_mit_extension unless it is explicitly specified */
-  if ((s = get_string_resource ("sgiSaverExtension", "Boolean")))
-    p->use_sgi_saver_extension = get_boolean_resource ("sgiSaverExtension",
-                                                      "Boolean");
-  else
-#ifdef HAVE_SGI_SAVER_EXTENSION                /* pick a default */
-    p->use_sgi_saver_extension = True; /* if we have it, use it */
-#else  /* !HAVE_SGI_SAVER_EXTENSION */
-    p->use_sgi_saver_extension = False;
-#endif /* !HAVE_SGI_SAVER_EXTENSION */
-  if (s) free (s);
-
-
-  /* Throttle the various timeouts to reasonable values.
-   */
-  if (p->passwd_timeout == 0) p->passwd_timeout = 30000;        /* 30 secs */
-  if (p->timeout < 10000) p->timeout = 10000;                   /* 10 secs */
-  if (p->cycle != 0 && p->cycle < 2000) p->cycle = 2000;        /*  2 secs */
-  if (p->pointer_timeout == 0) p->pointer_timeout = 5000;       /*  5 secs */
-  if (p->notice_events_timeout == 0)
-    p->notice_events_timeout = 10000;                           /* 10 secs */
-  if (p->fade_seconds == 0 || p->fade_ticks == 0)
-    p->fade_p = False;
-  if (! p->fade_p) p->unfade_p = False;
-
-  p->watchdog_timeout = p->cycle;
-  if (p->watchdog_timeout < 30000) p->watchdog_timeout = 30000;          /* 30 secs */
-  if (p->watchdog_timeout > 3600000) p->watchdog_timeout = 3600000; /*  1 hr */
-
-  get_screenhacks (si);
-
-  if (p->debug_p)
-    {
-      XSynchronize(si->dpy, True);
-      p->xsync_p = True;
-      p->verbose_p = True;
-      p->timestamp_p = True;
-      p->initial_delay = 0;
-    }
-
-  blurb_timestamp_p = p->timestamp_p;
+  si->prefs.fading_possible_p = found_any_writable_cells;
 }
 
 
@@ -756,94 +629,54 @@ initialize_server_extensions (saver_info *si)
 {
   saver_preferences *p = &si->prefs;
 
-  if (p->use_sgi_saver_extension)
-    {
+  Bool server_has_xidle_extension_p = False;
+  Bool server_has_sgi_saver_extension_p = False;
+  Bool server_has_mit_saver_extension_p = False;
+
+#ifdef HAVE_XIDLE_EXTENSION
+  server_has_xidle_extension_p = query_xidle_extension (si);
+#endif
 #ifdef HAVE_SGI_SAVER_EXTENSION
-      if (! query_sgi_saver_extension (si))
-       {
-         fprintf (stderr,
-        "%s: display %s does not support the SGI SCREEN_SAVER extension.\n",
-                  blurb(), DisplayString (si->dpy));
-         p->use_sgi_saver_extension = False;
-       }
-      else if (p->use_mit_saver_extension)
-       {
-         fprintf (stderr,
-                  "%s: SGI SCREEN_SAVER extension used instead"
-                  " of MIT-SCREEN-SAVER extension.\n",
-                  blurb());
-         p->use_mit_saver_extension = False;
-       }
-      else if (p->use_xidle_extension)
-       {
-         fprintf (stderr,
-        "%s: SGI SCREEN_SAVER extension used instead of XIDLE extension.\n",
-                  blurb());
-         p->use_xidle_extension = False;
-       }
-#else  /* !HAVE_MIT_SAVER_EXTENSION */
-      fprintf (stderr,
-              "%s: not compiled with support for the SGI SCREEN_SAVER"
-              " extension.\n",
-              blurb());
-      p->use_sgi_saver_extension = False;
-#endif /* !HAVE_SGI_SAVER_EXTENSION */
-    }
+  server_has_sgi_saver_extension_p = query_sgi_saver_extension (si);
+#endif
+#ifdef HAVE_MIT_SAVER_EXTENSION
+  server_has_mit_saver_extension_p = query_mit_saver_extension (si);
+#endif
 
-  if (p->use_mit_saver_extension)
+  if (!server_has_xidle_extension_p)
+    p->use_xidle_extension = False;
+  else if (p->verbose_p)
     {
-#ifdef HAVE_MIT_SAVER_EXTENSION
-      if (! query_mit_saver_extension (si))
-       {
-         fprintf (stderr,
-                  "%s: display %s does not support the MIT-SCREEN-SAVER"
-                  " extension.\n",
-                  blurb(), DisplayString (si->dpy));
-         p->use_mit_saver_extension = False;
-       }
-      else if (p->use_xidle_extension)
-       {
-         fprintf (stderr,
-                  "%s: MIT-SCREEN-SAVER extension used instead of XIDLE"
-                  " extension.\n",
-                  blurb());
-         p->use_xidle_extension = False;
-       }
-#else  /* !HAVE_MIT_SAVER_EXTENSION */
-      fprintf (stderr,
-              "%s: not compiled with support for the MIT-SCREEN-SAVER"
-              " extension.\n",
-              blurb());
-      p->use_mit_saver_extension = False;
-#endif /* !HAVE_MIT_SAVER_EXTENSION */
+      if (p->use_xidle_extension)
+       fprintf (stderr, "%s: using XIDLE extension.\n", blurb());
+      else
+       fprintf (stderr, "%s: not using server's XIDLE extension.\n", blurb());
     }
 
-  if (p->use_xidle_extension)
+  if (!server_has_sgi_saver_extension_p)
+    p->use_sgi_saver_extension = False;
+  else if (p->verbose_p)
     {
-#ifdef HAVE_XIDLE_EXTENSION
-      int first_event, first_error;
-      if (! XidleQueryExtension (si->dpy, &first_event, &first_error))
-       {
-         fprintf (stderr,
-                  "%s: display %s does not support the XIdle extension.\n",
-                  blurb(), DisplayString (si->dpy));
-         p->use_xidle_extension = False;
-       }
-#else  /* !HAVE_XIDLE_EXTENSION */
-      fprintf (stderr, "%s: not compiled with support for XIdle.\n", blurb());
-      p->use_xidle_extension = False;
-#endif /* !HAVE_XIDLE_EXTENSION */
+      if (p->use_sgi_saver_extension)
+       fprintf (stderr, "%s: using SGI SCREEN_SAVER extension.\n", blurb());
+      else
+       fprintf (stderr,
+                "%s: not using server's SGI SCREEN_SAVER extension.\n",
+                blurb());
     }
 
-  if (p->verbose_p && p->use_mit_saver_extension)
-    fprintf (stderr, "%s: using MIT-SCREEN-SAVER server extension.\n",
-            blurb());
-  if (p->verbose_p && p->use_sgi_saver_extension)
-    fprintf (stderr, "%s: using SGI SCREEN_SAVER server extension.\n",
-            blurb());
-  if (p->verbose_p && p->use_xidle_extension)
-    fprintf (stderr, "%s: using XIdle server extension.\n",
-            blurb());
+  if (!server_has_mit_saver_extension_p)
+    p->use_mit_saver_extension = False;
+  else if (p->verbose_p)
+    {
+      if (p->use_mit_saver_extension)
+       fprintf (stderr, "%s: using lame MIT-SCREEN-SAVER extension.\n",
+                blurb());
+      else
+       fprintf (stderr,
+                "%s: not using server's lame MIT-SCREEN-SAVER extension.\n",
+                blurb());
+    }
 }
 
 
@@ -864,7 +697,7 @@ select_events (saver_info *si)
       p->use_sgi_saver_extension)
     return;
 
-  if (p->initial_delay && !si->demo_mode_p)
+  if (p->initial_delay)
     {
       if (p->verbose_p)
        {
@@ -897,6 +730,25 @@ select_events (saver_info *si)
 }
 
 
+void
+maybe_reload_init_file (saver_info *si)
+{
+  saver_preferences *p = &si->prefs;
+  if (init_file_changed_p (p))
+    {
+      if (p->verbose_p)
+       fprintf (stderr, "%s: file \"%s\" has changed, reloading.\n",
+                blurb(), init_file_name());
+
+      load_init_file (p);
+
+      /* If a server extension is in use, and p->timeout has changed,
+        we need to inform the server of the new timeout. */
+      disable_builtin_screensaver (si, False);
+    }
+}
+
+
 /* Loop forever:
 
        - wait until the user is idle;
@@ -910,104 +762,112 @@ static void
 main_loop (saver_info *si)
 {
   saver_preferences *p = &si->prefs;
+  Bool ok_to_unblank;
+
   while (1)
     {
-      if (! si->demo_mode_p)
-       sleep_until_idle (si, True);
+      sleep_until_idle (si, True);
+
+      if (p->verbose_p)
+       {
+         if (si->demoing_p)
+           fprintf (stderr, "%s: demoing %d at %s.\n", blurb(),
+                    si->selection_mode, timestring());
+         else
+           if (p->verbose_p)
+             fprintf (stderr, "%s: blanking screen at %s.\n", blurb(),
+                      timestring());
+       }
 
       maybe_reload_init_file (si);
 
-#ifndef NO_DEMO_MODE
-      if (si->demo_mode_p)
-       demo_mode (si);
-      else
-#endif /* !NO_DEMO_MODE */
-       {
-         if (p->verbose_p)
-           fprintf (stderr, "%s: user is idle; waking up at %s.\n", blurb(),
-                    timestring());
-         maybe_reload_init_file (si);
-         blank_screen (si);
-         spawn_screenhack (si, True);
-         if (p->cycle)
-           si->cycle_id = XtAppAddTimeOut (si->app, p->cycle, cycle_timer,
-                                           (XtPointer) si);
+      blank_screen (si);
+      kill_screenhack (si);
+      spawn_screenhack (si, True);
+
+      /* Don't start the cycle timer in demo mode. */
+      if (!si->demoing_p && p->cycle)
+       si->cycle_id = XtAppAddTimeOut (si->app, p->cycle, cycle_timer,
+                                       (XtPointer) si);
+
 
 #ifndef NO_LOCKING
-         if (p->lock_p &&
-             !si->locking_disabled_p &&
-             p->lock_timeout == 0)
-           si->locked_p = True;
-
-         if (p->lock_p && !si->locked_p)
-           /* locked_p might be true already because of ClientMessage */
-           si->lock_id = XtAppAddTimeOut (si->app, p->lock_timeout,
-                                          activate_lock_timer,
-                                          (XtPointer) si);
+      if (!si->demoing_p &&            /* if not going into demo mode */
+         p->lock_p &&                  /* and locking is enabled */
+         !si->locking_disabled_p &&    /* and locking is possible */
+         p->lock_timeout == 0)         /* and locking is not timer-deferred */
+       si->locked_p = True;            /* then lock right now. */
+
+      /* locked_p might be true already because of the above, or because of
+        the LOCK ClientMessage.  But if not, and if we're supposed to lock
+        after some time, set up a timer to do so.
+       */
+      if (p->lock_p &&
+         !si->locked_p &&
+         p->lock_timeout > 0)
+       si->lock_id = XtAppAddTimeOut (si->app, p->lock_timeout,
+                                      activate_lock_timer,
+                                      (XtPointer) si);
 #endif /* !NO_LOCKING */
 
-       PASSWD_INVALID:
 
-         sleep_until_idle (si, False); /* until not idle */
-         maybe_reload_init_file (si);
+      ok_to_unblank = True;
+      do {
+
+       sleep_until_idle (si, False);           /* until not idle */
+       maybe_reload_init_file (si);
 
 #ifndef NO_LOCKING
-         if (si->locked_p)
-           {
-             Bool val;
-             if (si->locking_disabled_p) abort ();
-             si->dbox_up_p = True;
-
-             {
-               saver_screen_info *ssi = si->default_screen;
-               suspend_screenhack (si, True);
-               XUndefineCursor (si->dpy, ssi->screensaver_window);
-               if (p->verbose_p)
-                 fprintf (stderr, "%s: prompting for password.\n", blurb());
-               val = unlock_p (si);
-               if (p->verbose_p && val == False)
-                 fprintf (stderr, "%s: password incorrect!\n", blurb());
-               si->dbox_up_p = False;
-               XDefineCursor (si->dpy, ssi->screensaver_window, ssi->cursor);
-               suspend_screenhack (si, False);
-             }
-
-             if (! val)
-               goto PASSWD_INVALID;
-             si->locked_p = False;
-           }
+       if (si->locked_p)
+         {
+           saver_screen_info *ssi = si->default_screen;
+           if (si->locking_disabled_p) abort ();
+
+           si->dbox_up_p = True;
+           suspend_screenhack (si, True);
+           XUndefineCursor (si->dpy, ssi->screensaver_window);
+
+           ok_to_unblank = unlock_p (si);
+
+           si->dbox_up_p = False;
+           XDefineCursor (si->dpy, ssi->screensaver_window, ssi->cursor);
+           suspend_screenhack (si, False);     /* resume */
+         }
 #endif /* !NO_LOCKING */
 
-         if (p->verbose_p)
-           fprintf (stderr, "%s: user is active at %s.\n",
-                    blurb(), timestring ());
+       } while (!ok_to_unblank);
 
-         /* Let's kill it before unblanking, to get it to stop drawing as
-            soon as possible... */
-         kill_screenhack (si);
-         unblank_screen (si);
-         si->selection_mode = 0;
 
-         if (si->cycle_id)
-           {
-             XtRemoveTimeOut (si->cycle_id);
-             si->cycle_id = 0;
-           }
+      if (p->verbose_p)
+       fprintf (stderr, "%s: unblanking screen at %s.\n",
+                blurb(), timestring ());
 
-#ifndef NO_LOCKING
-         if (si->lock_id)
-           {
-             XtRemoveTimeOut (si->lock_id);
-             si->lock_id = 0;
-           }
-#endif /* !NO_LOCKING */
+      /* Kill before unblanking, to stop drawing as soon as possible. */
+      kill_screenhack (si);
+      unblank_screen (si);
+
+      si->locked_p = False;
+      si->demoing_p = 0;
+      si->selection_mode = 0;
+
+      if (si->cycle_id)
+       {
+         XtRemoveTimeOut (si->cycle_id);
+         si->cycle_id = 0;
+       }
 
-         if (p->verbose_p)
-           fprintf (stderr, "%s: going to sleep.\n", blurb());
+      if (si->lock_id)
+       {
+         XtRemoveTimeOut (si->lock_id);
+         si->lock_id = 0;
        }
+
+      if (p->verbose_p)
+       fprintf (stderr, "%s: awaiting idleness.\n", blurb());
     }
 }
 
+static void analyze_display (saver_info *si);
 
 int
 main (int argc, char **argv)
@@ -1015,6 +875,7 @@ main (int argc, char **argv)
   Widget shell;
   saver_info the_si;
   saver_info *si = &the_si;
+  saver_preferences *p = &si->prefs;
   int i;
 
   memset(si, 0, sizeof(*si));
@@ -1022,21 +883,27 @@ main (int argc, char **argv)
 
   srandom ((int) time ((time_t *) 0));
 
-  set_version_string (si, &argc, argv);
   save_argv (argc, argv);
+  set_version_string (si, &argc, argv);
   privileged_initialization (si, &argc, argv);
   hack_environment (si);
 
   shell = connect_to_server (si, &argc, argv);
   process_command_line (si, &argc, argv);
   print_banner (si);
-  initialize_per_screen_info (si, shell);
-  get_resources (si);
+
+  initialize_per_screen_info (si, shell);  /* also sets p->fading_possible_p */
 
   for (i = 0; i < si->nscreens; i++)
     if (ensure_no_screensaver_running (si->dpy, si->screens[i].screen))
       exit (1);
 
+  load_init_file (p);
+
+  if (p->xsync_p) XSynchronize (si->dpy, True);
+  blurb_timestamp_p = p->timestamp_p;  /* kludge */
+
+  if (p->verbose_p) analyze_display (si);
   initialize_server_extensions (si);
   initialize_screensaver_window (si);
   select_events (si);
@@ -1044,173 +911,12 @@ main (int argc, char **argv)
   disable_builtin_screensaver (si, True);
   initialize_stderr (si);
 
-  if (!si->demo_mode_p)
-    make_splash_dialog (si);
+  make_splash_dialog (si);
 
   main_loop (si);              /* doesn't return */
   return 0;
 }
 
-\f
-/* Parsing the programs resource.
- */
-
-static char *
-reformat_hack (const char *hack)
-{
-  int i;
-  const char *in = hack;
-  int indent = 13;
-  char *h2 = (char *) malloc(strlen(in) + indent + 2);
-  char *out = h2;
-
-  while (isspace(*in)) in++;           /* skip whitespace */
-  while (*in && !isspace(*in) && *in != ':')
-    *out++ = *in++;                    /* snarf first token */
-  while (isspace(*in)) in++;           /* skip whitespace */
-
-  if (*in == ':')
-    *out++ = *in++;                    /* copy colon */
-  else
-    {
-      in = hack;
-      out = h2;                                /* reset to beginning */
-    }
-
-  *out = 0;
-
-  while (isspace(*in)) in++;           /* skip whitespace */
-  for (i = strlen(h2); i < indent; i++)        /* indent */
-    *out++ = ' ';
-
-  /* copy the rest of the line. */
-  while (*in)
-    {
-      /* shrink all whitespace to one space, for the benefit of the "demo"
-        mode display.  We only do this when we can easily tell that the
-        whitespace is not significant (no shell metachars).
-       */
-      switch (*in)
-       {
-       case '\'': case '"': case '`': case '\\':
-         {
-           /* Metachars are scary.  Copy the rest of the line unchanged. */
-           while (*in)
-             *out++ = *in++;
-         }
-         break;
-       case ' ': case '\t':
-         {
-           while (*in == ' ' || *in == '\t')
-             in++;
-           *out++ = ' ';
-         }
-         break;
-       default:
-         *out++ = *in++;
-         break;
-       }
-    }
-  *out = 0;
-
-  /* strip trailing whitespace. */
-  out = out-1;
-  while (out > h2 && (*out == ' ' || *out == '\t' || *out == '\n'))
-    *out-- = 0;
-
-  return h2;
-}
-
-
-static void
-get_screenhacks (saver_info *si)
-{
-  saver_preferences *p = &si->prefs;
-  int i = 0;
-  int start = 0;
-  int end = 0;
-  int size;
-  char *d;
-
-  d = get_string_resource ("monoPrograms", "MonoPrograms");
-  if (d && !*d) { free(d); d = 0; }
-  if (!d)
-    d = get_string_resource ("colorPrograms", "ColorPrograms");
-  if (d && !*d) { free(d); d = 0; }
-
-  if (d)
-    {
-      fprintf (stderr,
-       "%s: the `monoPrograms' and `colorPrograms' resources are obsolete;\n\
-       see the manual for details.\n", blurb());
-      free(d);
-    }
-
-  d = get_string_resource ("programs", "Programs");
-
-  if (p->screenhacks)
-    {
-      for (i = 0; i < p->screenhacks_count; i++)
-       if (p->screenhacks[i])
-         free (p->screenhacks[i]);
-      free(p->screenhacks);
-      p->screenhacks = 0;
-    }
-
-  if (!d || !*d)
-    {
-      p->screenhacks_count = 0;
-      p->screenhacks = 0;
-      return;
-    }
-
-  size = strlen (d);
-
-
-  /* Count up the number of newlines (which will be equal to or larger than
-     the number of hacks.)
-   */
-  i = 0;
-  for (i = 0; d[i]; i++)
-    if (d[i] == '\n')
-      i++;
-  i++;
-
-  p->screenhacks = (char **) calloc (sizeof (char *), i+1);
-
-  /* Iterate over the lines in `d' (the string with newlines)
-     and make new strings to stuff into the `screenhacks' array.
-   */
-  p->screenhacks_count = 0;
-  while (start < size)
-    {
-      /* skip forward over whitespace. */
-      while (d[start] == ' ' || d[start] == '\t' || d[start] == '\n')
-       start++;
-
-      /* skip forward to newline or end of string. */
-      end = start;
-      while (d[end] != 0 && d[end] != '\n')
-       end++;
-
-      /* null terminate. */
-      d[end] = 0;
-
-      p->screenhacks[p->screenhacks_count++] = reformat_hack (d + start);
-      if (p->screenhacks_count >= i)
-       abort();
-
-      start = end+1;
-    }
-
-  if (p->screenhacks_count == 0)
-    {
-      free (p->screenhacks);
-      p->screenhacks = 0;
-    }
-}
-
-
 \f
 /* Processing ClientMessage events.
  */
@@ -1273,6 +979,7 @@ handle_clientmessage (saver_info *si, XEvent *event, Bool until_idle_p)
                                 "ACTIVATE ClientMessage received.",
                                 "activating.");
          si->selection_mode = 0;
+         si->demoing_p = False;
          if (p->use_mit_saver_extension || p->use_sgi_saver_extension)
            {
              XForceScreenSaver (si->dpy, ScreenSaverActive);
@@ -1316,6 +1023,7 @@ handle_clientmessage (saver_info *si, XEvent *event, Bool until_idle_p)
                                 "CYCLE ClientMessage received.",
                                 "cycling.");
          si->selection_mode = 0;       /* 0 means randomize when its time. */
+         si->demoing_p = False;
          if (si->cycle_id)
            XtRemoveTimeOut (si->cycle_id);
          si->cycle_id = 0;
@@ -1334,6 +1042,7 @@ handle_clientmessage (saver_info *si, XEvent *event, Bool until_idle_p)
                              : "PREV ClientMessage received."),
                             "cycling.");
       si->selection_mode = (type == XA_NEXT ? -1 : -2);
+      si->demoing_p = False;
 
       if (! until_idle_p)
        {
@@ -1357,6 +1066,7 @@ handle_clientmessage (saver_info *si, XEvent *event, Bool until_idle_p)
 
       if (which < 0) which = 0;                /* 0 == "random" */
       si->selection_mode = which;
+      si->demoing_p = False;
 
       if (! until_idle_p)
        {
@@ -1421,43 +1131,43 @@ handle_clientmessage (saver_info *si, XEvent *event, Bool until_idle_p)
     }
   else if (type == XA_DEMO)
     {
-#ifdef NO_DEMO_MODE
-      clientmessage_response (si, window, True,
-                             "not compiled with support for DEMO mode.",
-                             "demo mode not enabled.");
-#else /* !NO_DEMO_MODE */
-      if (until_idle_p)
+      long arg = event->xclient.data.l[1];
+      Bool demo_one_hack_p = (arg == 300);
+
+      if (demo_one_hack_p)
        {
-         clientmessage_response (si, window, False,
-                                 "DEMO ClientMessage received.",
-                                 "Demo mode.");
-         si->demo_mode_p = True;
-         return True;
+         if (until_idle_p)
+           {
+             long which = event->xclient.data.l[2];
+             char buf [255];
+             char buf2 [255];
+             sprintf (buf, "DEMO %ld ClientMessage received.", which);
+             sprintf (buf2, "demoing (%ld).", which);
+             clientmessage_response (si, window, False, buf, buf2);
+
+             if (which < 0) which = 0;         /* 0 == "random" */
+             si->selection_mode = which;
+             si->demoing_p = True;
+
+             return True;
+           }
+
+         clientmessage_response (si, window, True,
+                                 "DEMO ClientMessage received while active.",
+                                 "already active.");
+       }
+      else
+       {
+         clientmessage_response (si, window, True,
+                                 "obsolete form of DEMO ClientMessage.",
+                                 "obsolete form of DEMO ClientMessage.");
        }
-      clientmessage_response (si, window, True,
-                             "DEMO ClientMessage received while active.",
-                             "already active.");
-#endif /* !NO_DEMO_MODE */
     }
   else if (type == XA_PREFS)
     {
-#ifdef NO_DEMO_MODE
-      clientmessage_response (si, window, True,
-                             "not compiled with support for DEMO mode.",
-                             "preferences mode not enabled.");
-#else /* !NO_DEMO_MODE */
-      if (until_idle_p)
-       {
-         clientmessage_response (si, window, False,
-                                 "PREFS ClientMessage received.",
-                                 "preferences mode.");
-         si->demo_mode_p = (Bool) 2;  /* kludge, so sue me. */
-         return True;
-       }
       clientmessage_response (si, window, True,
-                             "PREFS ClientMessage received while active.",
-                             "already active.");
-#endif /* !NO_DEMO_MODE */
+                             "the PREFS client-message is obsolete.",
+                             "the PREFS client-message is obsolete.");
     }
   else if (type == XA_LOCK)
     {
@@ -1482,6 +1192,7 @@ handle_clientmessage (saver_info *si, XEvent *event, Bool until_idle_p)
                            : "locking.");
          si->locked_p = True;
          si->selection_mode = 0;
+         si->demoing_p = False;
          sprintf (buf, "LOCK ClientMessage received; %s", response);
          clientmessage_response (si, window, False, buf, response);
 
@@ -1531,3 +1242,72 @@ handle_clientmessage (saver_info *si, XEvent *event, Bool until_idle_p)
     }
   return False;
 }
+
+\f
+/* Some random diagnostics printed in -verbose mode.
+ */
+
+static void
+analyze_display (saver_info *si)
+{
+  int i, j;
+  static const char *exts[][2] = {
+    { "SCREEN_SAVER",     "SGI Screen-Saver" },
+    { "SCREEN-SAVER",     "SGI Screen-Saver" },
+    { "MIT-SCREEN-SAVER",  "MIT Screen-Saver" },
+    { "XIDLE",            "XIdle" },
+    { "SGI-VIDEO-CONTROL", "SGI Video-Control" },
+    { "READDISPLAY",      "SGI Read-Display" },
+    { "MIT-SHM",          "Shared Memory" },
+    { "DOUBLE-BUFFER",    "Double-Buffering" },
+    { "DPMS",             "Power Management" },
+    { "GLX",              "GLX" }
+  };
+
+  fprintf (stderr, "%s: running on display \"%s\"\n", blurb(),
+          DisplayString(si->dpy));
+  fprintf (stderr, "%s: vendor is %s, %d\n", blurb(),
+          ServerVendor(si->dpy), VendorRelease(si->dpy));
+
+  fprintf (stderr, "%s: useful extensions:\n", blurb());
+  for (i = 0; i < countof(exts); i++)
+    {
+      int op = 0, event = 0, error = 0;
+      if (XQueryExtension (si->dpy, exts[i][0], &op, &event, &error))
+       fprintf (stderr, "%s:   %s\n", blurb(), exts[i][1]);
+    }
+
+  for (i = 0; i < si->nscreens; i++)
+    {
+      unsigned long colormapped_depths = 0;
+      unsigned long non_mapped_depths = 0;
+      XVisualInfo vi_in, *vi_out;
+      int out_count;
+      vi_in.screen = i;
+      vi_out = XGetVisualInfo (si->dpy, VisualScreenMask, &vi_in, &out_count);
+      if (!vi_out) continue;
+      for (j = 0; j < out_count; j++)
+       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)
+       {
+         fprintf (stderr, "%s: screen %d colormapped depths:", blurb(), i);
+         for (j = 0; j < 32; j++)
+           if (colormapped_depths & (1 << j))
+             fprintf (stderr, " %d", j);
+         fprintf (stderr, "\n");
+       }
+      if (non_mapped_depths)
+       {
+         fprintf (stderr, "%s: screen %d non-mapped depths:", blurb(), i);
+         for (j = 0; j < 32; j++)
+           if (non_mapped_depths & (1 << j))
+             fprintf (stderr, " %d", j);
+         fprintf (stderr, "\n");
+       }
+    }
+}
index 6fc68ba855b755580665ea5afed0e54f114abec0..467932f6aa4550ff66bce40fcbb3cfe2c6af3afe 100644 (file)
 #include <string.h>
 #include <stdio.h>
 
+#include "prefs.h"
+
 extern char *progname;
 extern char *progclass;
 
-typedef struct saver_preferences saver_preferences;
 typedef struct saver_info saver_info;
 typedef struct saver_screen_info saver_screen_info;
 typedef struct passwd_dialog_data passwd_dialog_data;
@@ -34,53 +35,12 @@ typedef struct splash_dialog_data splash_dialog_data;
 
 
 
-/* This structure holds all the user-specified parameters, read from the
-   command line, the resource database, or entered through a dialog box.
- */
-struct saver_preferences {
-  Bool verbose_p;              /* whether to print out lots of status info */
-  Bool timestamp_p;            /* whether to mark messages with a timestamp */
-  Bool debug_p;                        /* pay no mind to the man behind the curtain */
-  Bool xsync_p;                        /* whether XSynchronize has been called */
-
-  Bool lock_p;                 /* whether to lock as well as save */
-  Bool lock_vt_p;              /* whether to lock VTs too, if possible */
-  Bool fade_p;                 /* whether to fade to black, if possible */
-  Bool unfade_p;               /* whether to fade from black, if possible */
-  int fade_seconds;            /* how long that should take */
-  int fade_ticks;              /* how many ticks should be used */
-
-  Bool install_cmap_p;         /* whether we should use our own colormap
-                                  when using the screen's default visual. */
-
-  char **screenhacks;          /* the programs to run */
-  int screenhacks_count;
-
-  int nice_inferior;           /* nice value for subprocs */
-
-  Time initial_delay;          /* how long to sleep after launch */
-  Time splash_duration;                /* how long the splash screen stays up */
-  Time timeout;                        /* how much idle time before activation */
-  Time lock_timeout;           /* how long after activation locking starts */
-  Time cycle;                  /* how long each hack should run */
-  Time passwd_timeout;         /* how much time before pw dialog goes down */
-  Time pointer_timeout;                /* how often to check mouse position */
-  Time notice_events_timeout;  /* how long after window creation to select */
-  Time watchdog_timeout;       /* how often to re-raise and re-blank screen */
-
-  Bool use_xidle_extension;    /* which extension to use, if possible */
-  Bool use_mit_saver_extension;
-  Bool use_sgi_saver_extension;
-
-  char *shell;                 /* where to find /bin/sh */
-
-  char *help_url;              /* Where the help document resides. */
-  char *load_url_command;      /* How one loads URLs. */
-};
-
-
 /* This structure holds all the data that applies to the program as a whole,
    or to the non-screen-specific parts of the display connection.
+
+   The saver_preferences structure (prefs.h) holds all the user-specified
+   parameters, read from the command line, the resource database, or entered
+   through a dialog box.
  */
 struct saver_info {
   char *version;
@@ -90,9 +50,6 @@ struct saver_info {
   saver_screen_info *screens;
   saver_screen_info *default_screen;   /* ...on which dialogs will appear. */
 
-  time_t init_file_date;       /* The date (from stat()) of the .xscreensaver
-                                  file the last time this process read or
-                                  wrote it. */
 
   /* =======================================================================
      global connection info
@@ -100,7 +57,6 @@ struct saver_info {
 
   XtAppContext app;
   Display *dpy;
-  XrmDatabase db;
 
   /* =======================================================================
      server extension info
@@ -123,7 +79,6 @@ struct saver_info {
   Bool screen_blanked_p;       /* Whether the saver is currently active. */
   Window mouse_grab_window;    /* Window holding our mouse grab */
   Window keyboard_grab_window; /* Window holding our keyboard grab */
-  Bool fading_possible_p;      /* Whether fading to/from black is possible. */
 
 
   /* =======================================================================
@@ -149,14 +104,16 @@ struct saver_info {
   Window passwd_dialog;                /* The password dialog, if its up. */
   passwd_dialog_data *pw_data; /* Other info necessary to draw it. */
 
+  int unlock_failures;         /* Counts failed login attempts while the
+                                  screen is locked. */
+
 
   /* =======================================================================
      demoing
      ======================================================================= */
 
-  Bool demo_mode_p;            /* Whether demo-mode is active */
-  char *demo_hack;             /* The hack that has been selected from the
-                                  dialog box, which should be run next. */
+  Bool demoing_p;              /* Whether we are demoing a single hack
+                                  (without UI.) */
 
   Window splash_dialog;                /* The splash dialog, if its up. */
   splash_dialog_data *sp_data; /* Other info necessary to draw it. */
@@ -182,8 +139,9 @@ struct saver_info {
 
   int selection_mode;          /* Set to -1 if the NEXT ClientMessage has just
                                   been received; set to -2 if PREV has just
-                                  been received; set to N if SELECT has
-                                  been received.  (This is kind of nasty.) */
+                                  been received; set to N if SELECT or DEMO N
+                                  has been received.  (This is kind of nasty.)
+                                */
 
   /* =======================================================================
      subprocs
@@ -276,7 +234,7 @@ struct saver_screen_info {
    ======================================================================= */
 
 extern void restore_real_vroot (saver_info *si);
-extern void disable_builtin_screensaver (saver_info *si, Bool turn_off_p);
+extern void disable_builtin_screensaver (saver_info *, Bool unblank_screen_p);
 extern Bool ensure_no_screensaver_running (Display *, Screen *);
 
 #ifdef HAVE_MIT_SAVER_EXTENSION
@@ -285,6 +243,9 @@ extern Bool query_mit_saver_extension (saver_info *);
 #ifdef HAVE_SGI_SAVER_EXTENSION
 extern Bool query_sgi_saver_extension (saver_info *);
 #endif
+#ifdef HAVE_XIDLE_EXTENSION
+extern Bool query_xidle_extension (saver_info *);
+#endif
 
 /* Display Power Management System (DPMS) interface. */
 extern Bool monitor_powered_on_p (saver_info *si);
@@ -301,7 +262,7 @@ extern void raise_window (saver_info *si,
                            Bool dont_clear);
 extern void blank_screen (saver_info *si);
 extern void unblank_screen (saver_info *si);
-extern void grab_keyboard_and_mouse (saver_info *si, Window, Cursor);
+extern Bool grab_keyboard_and_mouse (saver_info *si, Window, Cursor);
 extern void ungrab_keyboard_and_mouse (saver_info *si);
 
 /* =======================================================================
@@ -340,20 +301,6 @@ extern void draw_shaded_rectangle (Display *dpy, Window window,
                                   unsigned long bottom_color);
 extern int string_width (XFontStruct *font, char *s);
 
-
-#ifndef NO_DEMO_MODE
-extern void demo_mode (saver_info *si);
-extern void demo_mode_restart_process (saver_info *si);
-extern void create_demo_dialog (Widget, Visual *, Colormap);
-extern void create_resources_dialog (Widget, Visual *, Colormap);
-#endif
-
-#if !defined(NO_LOCKING) || !defined(NO_DEMO_MODE)
-extern void pop_up_dialog_box (Widget dialog, Widget form, int where);
-extern void format_into_label (Widget label, const char *arg);
-extern void steal_focus_and_colormap (Widget dialog);
-#endif
-
 extern void make_splash_dialog (saver_info *si);
 extern void handle_splash_event (saver_info *si, XEvent *e);
 extern void skull (Display *, Window, GC, GC, int, int, int, int);
@@ -375,12 +322,14 @@ extern void sleep_until_idle (saver_info *si, Bool until_idle_p);
    ======================================================================= */
 
 extern Bool handle_clientmessage (saver_info *, XEvent *, Bool);
+extern void maybe_reload_init_file (saver_info *);
 
 /* =======================================================================
    subprocs
    ======================================================================= */
 
 extern void hack_environment (saver_info *si);
+extern void hack_subproc_environment (saver_screen_info *ssi);
 extern void init_sigchld (void);
 extern void spawn_screenhack (saver_info *si, Bool first_time_p);
 extern void kill_screenhack (saver_info *si);
@@ -400,15 +349,6 @@ extern void initialize_stderr (saver_info *si);
 extern void reset_stderr (saver_screen_info *ssi);
 extern void clear_stderr (saver_screen_info *ssi);
 
-/* =======================================================================
-   the .xscreensaver file
-   ======================================================================= */
-
-extern int read_init_file (saver_info *si);
-extern int write_init_file (saver_info *si);
-extern int maybe_reload_init_file (saver_info *si);
-extern void get_resources (saver_info *si);
-
 
 /* =======================================================================
    misc
index bc97d345ad212750b98c98d0b7efe5e2cd669aa1..ac9326ca39f11121ffcf81a7b73488927140613d 100644 (file)
@@ -11,7 +11,7 @@
 .if n .sp 1
 .if t .sp .5
 ..
-.TH XScreenSaver 1 "08-Oct-98 (2.34)" "X Version 11"
+.TH XScreenSaver 1 "24-Oct-98 (3.01)" "X Version 11"
 .SH NAME
 xscreensaver - graphics hack and screen locker, launched when the user is idle
 .SH SYNOPSIS
@@ -60,69 +60,21 @@ mode.
 For the impatient, try this:
 .EX
 xscreensaver &
-xscreensaver-command -demo
+xscreensaver-demo
 .EE
-After a few seconds, the screen should go black, and a dialog box should
-appear in the upper right corner.  This is \fIDemo Mode\fP.
+The \fIxscreensaver\-demo\fP program should pop up a dialog box
+that lets you experiment with the xscreensaver settings and graphics
+modes.
 
 .B Note:
 unlike
 .BR xlock (1),
-xscreensaver has a client-server model: the xscreensaver process is a
+xscreensaver has a client-server model: the \fIxscreensaver\fP program is a
 daemon that runs in the background; it is controlled by the foreground
+.BR xscreensaver-demo (1)
+and
 .BR xscreensaver-command (1)
-program.
-.SH DEMO MODE
-If \fIxscreensaver\fP receives the \fBDEMO\fP ClientMessage, which is done
-by running the
-.BR xscreensaver\-command (1)
-program with the \fB\-demo\fP option, the screensaver will black the screen
-and pop up a dialog box from which you can examine and experiment with the
-client programs.
-
-The dialog box contains a scrolling list, a text field, and a number of 
-buttons.  
-
-Double-clicking on one of the programs in the list will run it.  The dialog
-box will disappear, allowing the program access to the full screen.  Clicking
-the mouse again will bring the dialog box back.
-
-Single-clicking in the list will place the indicated program and its args
-in the text field to be edited.  Edit the arguments and hit return to run
-the program with the parameters you have specified.  (Note that these are
-one-time changes and won't be remembered; to make the changes permanent,
-you need to edit your \fI~/.xscreensaver\fP file by hand.)
-
-The buttons are:
-.TP 8
-.B Run Next
-Clicking this button will run the next program in the list after the 
-currently-selected one, and will wrap around to the top when it reaches
-the bottom.
-.TP 8
-.B Run Previous
-Opposite of Run Next; at the top, it wraps around to the bottom.
-.TP 8
-.B Preferences
-This pops up a second dialog box, in which you have the option to 
-interactively change most of the screensaver's operational parameters,
-such as its timeouts, and whether it should lock the screen.  When you
-click OK, your chosen settings will take effect immediately, and will
-also be saved to the \fI~/.xscreensaver\fP file in your home directory,
-so that the settings will persist next time.  (For more details, see
-the \fIConfiguration\fP section, below.)
-.TP 8
-.B Exit Demo Mode
-Returns to normal screensaver operation.
-.TP 8
-.B Reinitialize
-This causes the X resource database to be re-read, to pick up any changes
-you might have made.  This works by causing the screensaver process to exit
-and then restart itself with the same command-line arguments.  This is just
-like the \fI\-restart\fP argument to 
-.BR xscreensaver\-command (1)
-except that when executed from this button, the screensaver will 
-automatically return to Demo Mode after restarting.
+programs.
 .SH CONFIGURATION
 Options to \fIxscreensaver\fP are specified in one of two places: in 
 a \fI.xscreensaver\fP file in your home directory; or in the X resource
@@ -285,6 +237,14 @@ This is the shell command used to load a URL into your web browser.
 The default setting will load it into Netscape if it is already running,
 otherwise, will launch a new Netscape looking at the \fIhelpURL\fP.
 .TP 8
+.B demoCommand\fP (class \fBDemoCommand\fP)
+This is the shell command run when the \fIDemo\fP button on the splash window
+is pressed.  It defaults to \fIxscreensaver\-demo\fP.
+.TP 8
+.B prefsCommand\fP (class \fBPrefsCommand\fP)
+This is the shell command run when the \fIPrefs\fP button on the splash window
+is pressed.  It defaults to \fIxscreensaver\-demo\ \-prefs\fP.
+.TP 8
 .B nice\fP (class \fBNice\fP)
 The sub-processes created by \fIxscreensaver\fP will be ``niced'' to this
 level, so that they are given lower priority than other processes on the
@@ -620,15 +580,82 @@ See the man page for the
 program for details.  (Note that power management requires both software
 support in the X server, and hardware support in the monitor itself.)
 .SH USING XDM(1)
-You can run \fIxscreensaver\fP from your xdm session, so that the 
-screensaver will run even when nobody is logged in on the console.  
-Simply add \fB"xscreensaver &"\fP to your \fI/usr/lib/X11/xdm/Xsetup\fP 
-file.  Because \fIxdm\fP grabs the keyboard, keypresses will not make 
-the screensaver deactivate, but any mouse activity will.
+You can run \fIxscreensaver\fP from your 
+.BR xdm (1)
+session, so that the screensaver will run even when nobody is logged 
+in on the console.
+
+The trick to using xscreensaver with \fIxdm\fP is this: keep in mind the 
+two very different states in which xscreensaver will be running:
+.RS 4
+.TP 3
+.B 1: Nobody logged in.
+
+If you're thinking of running xscreensaver from XDM at all, then it's 
+probably because you want graphics demos to be running on the console
+when nobody is logged in there.  In this case, xscreensaver will function
+only as a screen saver, not a screen locker: it doesn't make sense
+for xscreensaver to lock the screen, since nobody is logged in yet!
+The only thing on the screen is the XDM login prompt.
+.TP 3
+.B 2: Somebody logged in.
+
+Once someone has logged in through the XDM login window, the situation is
+very different.  For example: now it makes sense to lock the screen (and
+prompt for the logged in user's password); and now xscreensaver should
+consult that user's \fI~/.xscreensaver\fP file; and so on.
+.RE
+
+The difference between these two states comes down to a question of,
+which user is the \fIxscreensaver\fP process running as?  For the first
+state, it doesn't matter.  If you start \fIxscreensaver\fP in the usual
+XDM way, then xscreensaver will probably end up running as root, which 
+is fine for the first case (the ``nobody logged in'' case.)
+
+However, once someone is logged in, running as root is no longer fine:
+because xscreensaver will be consulting root's \fI.xscreensaver\fP file
+instead of that of the logged in user, and won't be prompting for the
+logged in user's password, and so on.  (This is not a security problem,
+it's just not what you want.)
+
+So, once someone has logged in, you want xscreensaver to be running as that
+user.  The way to accomplish this is to kill the old xscreensaver process
+and start a new one (as the new user.)
+
+The simplest way to accomplish all of this is as follows:
+.RS 4
+.TP 3
+.B 1: Launch xscreensaver before anyone logs in.
+
+To the file \fI/usr/lib/X11/xdm/Xsetup\fP, add the lines
+.EX
+xscreensaver-command -exit
+xscreensaver &
+.EE
+This will run xscreensaver as root, over the XDM login window.
+Moving the mouse will cause the screen to un-blank, and allow the user
+to type their password at XDM to log in.
+.TP 3
+.B 2: Restart xscreensaver when someone logs in.
 
-Make sure you have \fB$PATH\fP set up correctly in the Xsetup script, or
-\fIxdm\fP won't be able to find \fIxscreensaver\fP, and/or \fIxscreensaver\fP
-won't be able to find its graphics hacks.
+Near the top of the file \fI/usr/lib/X11/xdm/Xsession\fP, add those same lines:
+.EX
+xscreensaver-command -exit
+xscreensaver &
+.EE
+When someone logs in, this will kill off the existing (root) xscreensaver
+process, and start a new one, running as the user who has just logged in.
+If the user's .xscreensaver file requests locking, they'll get it.  They
+will also get their own choice of timeouts, and graphics demos, and so on.
+
+Alternately, each user could just put those lines in their 
+personal \fI~/.xsession\fP files.
+.RE
+
+Make sure you have \fB$PATH\fP set up correctly in the \fIXsetup\fP 
+and \fIXsession\fP scripts, or \fIxdm\fP won't be able to 
+find \fIxscreensaver\fP, and/or \fIxscreensaver\fP won't be able to 
+find its graphics demos.
 
 (If your system does not seem to be executing the \fIXsetup\fP file, you
 may need to configure it to do so: the traditional way to do this is
@@ -637,25 +664,14 @@ in the \fI/usr/lib/X11/xdm/xdm-config\fP file.  See the man page for
 .BR xdm (1)
 for more details.)
 
-Users may want to add \fB"xscreensaver-command -restart"\fP to their 
-startup scripts, so that the screensaver will be reinitialized with
-their private resource settings when they log in.  Users who don't do
-this will get the system-wide defaults instead.
-
-It is safe to run this program as root (as \fIxdm\fP is likely to do.)  If 
-run as root, \fIxscreensaver\fP changes its effective user and group ids to
-something safe (like \fI"nobody"\fP) before connecting to the X server
+It is safe to run \fIxscreensaver\fP as root (as \fIxdm\fP is likely to do.)  
+If run as root, \fIxscreensaver\fP changes its effective user and group ids 
+to something safe (like \fI"nobody"\fP) before connecting to the X server
 or launching user-specified programs.
 
-Locking doesn't work if the screensaver is launched by \fIxdm\fP.  To get
-around this, you can run the screensaver from \fIxdm\fP without locking, 
-and kill and restart it from your personal X startup script to enable
-locking; for example, by using this pair of commands:
+An unfortunate side effect of this (important) security precaution is that
+it may conflict with cookie-based authentication.
 
-.EX
-xscreensaver-command -exit
-xscreensaver
-.EE
 If you get "connection refused" errors when running \fIxscreensaver\fP
 from \fIxdm\fP, then this probably means that you have
 .BR xauth (1)
@@ -666,9 +682,9 @@ is launched.
 Note that this will give access to the X server to anyone capable of logging
 in to the local machine, so in some environments, this might not be 
 appropriate.  If turning off file-system-based access control is not
-acceptable, then running \fIxscreensaver\fP from \fIxdm\fP might not be
-possible, and users will have to launch it themselves instead of having it
-be launched by \fIxdm\fP before anyone logs in.
+acceptable, then running \fIxscreensaver\fP from the \fIXsetup\fP file
+might not be possible, and xscreensaver will only work when running as
+a normal, unprivileged user.
 
 For more information on the X server's access control mechanisms, see the
 man pages for
@@ -693,7 +709,6 @@ Screen section of the Style Manager.
 .TP 3
 \fB2: Edit sessionetc\fP
 Edit the file \fI~/.dt/sessions/sessionetc\fP and add to it the line
-
 .EX
 xscreensaver &
 .EE
@@ -705,7 +720,6 @@ and/or \fI.dtprofile\fP, not \fI.login\fP.)
 \fB3: Create XScreenSaver.dt\fP
 Create a file called \fI~/.dt/types/XScreenSaver.dt\fP with the following
 contents:
-
 .EX
 ACTION XScreenSaver
 {
@@ -722,7 +736,6 @@ to talk to \fIxscreensaver\fP.
 \fB4: Create Lock.fp\fP
 Create a file called \fI~/.dt/types/Lock.fp\fP with the following
 contents:
-
 .EX
 CONTROL Lock
 {
@@ -748,7 +761,6 @@ file \fI~/.dt/errorlog\fP for error messages.
 .SH USING HP VUE (VISUAL USER ENVIRONMENT)
 Since CDE is a descendant of VUE, the instructions for using xscreensaver
 under VUE are similar to the above:
-
 .RS 4
 .TP 3
 \fB1: Switch off VUE's locker\fP
@@ -811,8 +823,8 @@ menu XScreenSaver
 {
  "Blank Screen Now" !"sleep 3; xscreensaver-command -activate"
  "Lock Screen Now"  !"sleep 3; xscreensaver-command -lock"
- "Screen Saver Demo"         !"xscreensaver-command -demo"
- "Screen Saver Preferences"  !"xscreensaver-command -prefs"
+ "Screen Saver Demo"         !"xscreensaver-demo"
+ "Screen Saver Preferences"  !"xscreensaver-demo -prefs"
  "Reinitialize Screen Saver" !"xscreensaver-command -restart"
  "Kill Screen Saver"         !"xscreensaver-command -exit"
  "Launch Screen Saver"       !"xscreensaver &"
@@ -833,75 +845,27 @@ in that menu definition that reads
   "XScreenSaver"        f.menu XScreenSaver
 .EE
 then this will add an XScreenSaver sub-menu to your default root-window
-popup menu.  Alternately, you could just put the \fIxscreensaver-command\fP
-menu items directly into the root menu.
+popup menu.  Alternately, you could just put the xscreensaver menu items
+directly into the root menu.
 .RE
 
-Other window managers might (and probably do) do things differently.
+Other window managers are guaranteed to do things gratuitously differently.
 .SH BUGS
-(This is not a bug, but) note that as of release 1.32, the \fBcolorPrograms\fP 
-and \fBmonoPrograms\fP resources are no longer used: they have been 
-supplanted by the extended syntax of the \fBprograms\fP resource (which is
-described in the \fIConfiguration\fP section, above.)
-.TP 8
-.B Extensions
-If you are not making use of one of the server extensions (\fBXIDLE\fP,
-\fBSGI SCREEN_SAVER\fP, or \fBMIT-SCREEN-SAVER\fP), then it is possible, in 
-rare situations, for \fIxscreensaver\fP to interfere with event propagation 
-and make another X program malfunction.  For this to occur, that other
-application would need to \fInot\fP select \fBKeyPress\fP events on its 
-non-leaf windows within the first 30 seconds of their existence, but then 
-select for them later.  In this case, that client \fImight\fP fail to receive 
-those events.  This isn't very likely, since programs generally select a
-constant set of events immediately after creating their windows and then 
-don't change them, but this is the reason that it's a good idea to install 
-and use one of the server extensions instead, to work around this shortcoming
-in the X protocol.
-.TP 8
-.B Machine Load
-Although this program ``nices'' the subprocesses that it starts, 
-graphics-intensive subprograms can still overload the machine by causing
-the X server process itself (which is not ``niced'') to suck a lot of 
-cycles.  Care should be taken to slow down programs intended for use as 
-screensavers by inserting strategic calls to
-.BR sleep (3)
-or
-.BR usleep (3)
-(or making liberal use of any \fI\-delay\fP options which the programs 
-may provide.)
-
-Also, an active screensaver will cause your X server to be pretty much 
-permanently swapped in; but the same is true of any program that draws
-periodically, like 
-.BR xclock (1)
-or
-.BR xload (1).
-.TP 8
-.B Latency and Responsiveness
-If the subprocess is drawing too quickly and the connection to the X
-server is a slow one (such as an X terminal running over a phone line) then 
-the screensaver might not turn off right away when the user becomes active
-again (the
-.BR ico (1)
-demo has this problem if being run in full-speed mode).  This can be
-alleviated by inserting strategic calls to
-.BR XSync (3)
-in code intended for use as a screensaver.  This prevents too much graphics
-activity from being buffered up.
+Bugs?  There are no bugs.  Ok, well, maybe.  If you find one, please let
+me know.  http://www.jwz.org/xscreensaver/bugs.html explains how to
+construct the most useful bug reports.
 .TP 8
 .B Locking and XDM
 If xscreensaver has been launched from 
-.BR xdm (1),
-you will need to cause the xscreensaver daemon to exit and restart in 
-order to lock the screen.
+.BR xdm (1)
+before anyone has logged in, you will need to kill and then restart the
+xscreensaver daemon after you have logged in, or you will be confused by
+the results.  (For example, locking won't work, and your \fI~/.xscreensaver\fP
+file will be ignored.)
 
-The reason for this is, if xscreensaver has been launched by 
-.BR xdm (1),
-that means it was launched \fIbefore\fP you logged in: so it has no way of
-knowing who the logged-in user is, and therefore, whose password it should
-prompt for.
+When you are logged in, you want the \fIxscreensaver\fP daemon to be 
+running under \fIyour\fP user id, not as root or some other user.
 
-So if you want to use it as a locker, you must start it with your user id.
 If it has already been started by \fIxdm\fP, you can kill it by sending
 it the \fBexit\fP command, and then re-launching it as you, by putting
 something like the following in your personal X startup script:
@@ -909,34 +873,44 @@ something like the following in your personal X startup script:
 xscreensaver-command -exit
 xscreensaver &
 .EE
-See the ``\fIUsing XDM(1)\fP'' section, above, for more details.
+The ``\fIUsing XDM(1)\fP'' section, above, goes into more detail, and explains
+how to configure the system to do this for all users automatically.
 .TP 8
 .B Locking and root logins
-An implication of the above is that if you log in as \fIroot\fP on the
-console, xscreensaver will refuse to lock the screen (because it can't tell
+In order for it to be safe for xscreensaver to be launched by \fIxdm\fP,
+certain precautions had to be taken, among them that xscreensaver never
+runs as \fIroot\fP.  In particular, if it is launched as root (as \fIxdm\fP
+is likely to do), xscreensaver will disavow its privileges, and switch to
+a safe user id (such as \fInobody\fP.)
+
+An implication of this is that if you log in as \fIroot\fP on the console, 
+xscreensaver will refuse to lock the screen (because it can't tell
 the difference between \fIroot\fP being logged in on the console, and a
-normal user being logged in on the console but xscreensaver having been run
-by
-.BR xdm (1)).
+normal user being logged in on the console but xscreensaver having been 
+launched by the
+.BR xdm (1)
+.I Xsetup
+file.)
 
 The solution to this is simple: you shouldn't be logging in on the console
-as \fIroot\fP in the first place!  (What, are you crazy or something?)  You 
-should log in as you, and
+as \fIroot\fP in the first place!  (What, are you crazy or something?)  
+
+Proper Unix hygiene dictates that you should log in as yourself, and
 .BR su (1)
-to \fIroot\fP as necessary.  People who spend their day logged in 
+to \fIroot\fP as necessary.  People who spend their day logged in
 as \fIroot\fP are just begging for disaster.
 .TP 8
 .B XAUTH and XDM
 For xscreensaver to work when launched by
 .BR xdm (1),
 programs running on the local machine as user \fI"nobody"\fP must be
-able to connect to the X server.  This means that \fB"xhost +localhost"\fP
-is required if xscreensaver is to be launched by
-.BR xdm (1).
-This is \fInot\fP required if \fIxscreensaver\fP is launched by the
-individual users: it is only necessary when it is launched by
-.BR xdm (1),
-before any user has logged in.  See the ``\fIUsing XDM(1)\fP'' section, 
+able to connect to the X server.  This means that if you want to run
+xscreensaver on the console while nobody is logged in, you may need
+to disable cookie-based access control (and allow all users who can log
+in to the local machine to connect to the display.)  
+
+You should be sure that this is an acceptable thing to do in your
+environment before doing it.  See the ``\fIUsing XDM(1)\fP'' section, 
 above, for more details.
 
 If anyone has suggestions on how xscreensaver could be made to work with
@@ -952,9 +926,10 @@ library routine can only be effectively used by root.  If this is the case,
 then \fIxscreensaver\fP must be installed as setuid to root.  Care has 
 been taken to make this a safe thing to do.  
 
-It also may mean that your system uses shadow passwords instead of the
-standard \fIgetpwent\fP interface; in that case, you may need to change
-some options with \fIconfigure\fP and recompile.
+It also may mean that your system uses shadow passwords instead of the standard
+.BR getpwent (3)
+interface; in that case, you may need to change some options 
+with \fIconfigure\fP and recompile.
 
 If you change your password after xscreensaver has been launched, it will
 continue using your old password to unlock the screen until xscreensaver
@@ -1003,6 +978,51 @@ It would also work to turn off the \fBinstallColormap\fP option altogether,
 but that would deny extra colors to those programs that \fIcan\fP take
 advantage of them.
 .TP 8
+.B Machine Load
+Although this program ``nices'' the subprocesses that it starts, 
+graphics-intensive subprograms can still overload the machine by causing
+the X server process itself (which is not ``niced'') to suck a lot of 
+cycles.  Care should be taken to slow down programs intended for use as 
+screensavers by inserting strategic calls to
+.BR sleep (3)
+or
+.BR usleep (3)
+(or making liberal use of any \fI\-delay\fP options which the programs 
+may provide.)
+
+Note that the OpenGL-based graphics demos are real pigs on machines that
+don't have texture hardware.
+
+Also, an active screensaver will cause your X server to be pretty much 
+permanently swapped in; but the same is true of any program that draws
+periodically, like 
+.BR xclock (1)
+or
+.BR xload (1).
+.TP 8
+.B Doom and Quake
+On some systems, Doom, Quake, and other games intercept the keyboard in
+ways that X programs can never detect.  Therefore, when running these games,
+xscreensaver might think the console is idle, and activate.  In the worst
+case, xscreensaver might blank the screen and mess up the game.  Alternately,
+xscreensaver might activate on the X display while leaving the game visible,
+and merely cause the game to slow down.
+
+I don't know how to fix this, because I don't know how to detect the kind 
+of keyboard activity that occurs during these games.  Suggestions are welcome.
+.TP 8
+.B Latency and Responsiveness
+If the subprocess is drawing too quickly and the connection to the X
+server is a slow one (such as an X terminal running over a phone line) then 
+the screensaver might not turn off right away when the user becomes active
+again (the
+.BR ico (1)
+demo has this problem if being run in full-speed mode).  This can be
+alleviated by inserting strategic calls to
+.BR XSync (3)
+in code intended for use as a screensaver.  This prevents too much graphics
+activity from being buffered up.
+.TP 8
 .B XView Clients
 Apparently there are some problems with XView programs getting confused
 and thinking that the screensaver window is the real root window even when
@@ -1014,8 +1034,10 @@ cause of this problem, please let me know.  (XView is an X11 toolkit that
 implements the (quite abominable) Sun OpenLook look-and-feel.)
 .TP 8
 .B MIT Extension and Fading
+The \fBMIT-SCREEN-SAVER\fP extension is junk.  Don't use it.
+
 When using the \fBMIT-SCREEN-SAVER\fP extension in conjunction with 
-the \fBfade\fP option, you may notice an unattractive flicker just before 
+the \fBfade\fP option, you'll notice an unattractive flicker just before 
 the fade begins.  This is because the server maps a black window just before 
 it tells the \fIxscreensaver\fP process to activate.  The \fIxscreensaver\fP 
 process immediately unmaps that window, but this results in a flicker.  I 
@@ -1023,18 +1045,9 @@ haven't figured a way  to get around this; it seems to be a fundamental
 property of the (mis-) design of this server extension.
 
 It sure would be nice if someone would implement the \fBSGI SCREEN_SAVER\fP
-extension in XFree86; it's dead simple, and works far better than the 
+extension in XFree86; it's dead simple, and works far better than the
 overengineered and broken \fBMIT-SCREEN-SAVER\fP extension.
 .TP 8
-.B Lesstif (Motif clone)
-\fIDemo Mode\fP is buggy if XScreenSaver was compiled against really old 
-versions Lesstif; if you use Lesstif, make sure you use version 0.82 or newer.
-.TP 8
-.B Athena Widgets
-If you compiled against the Athena widget toolkit, the dialog boxes are
-pretty ugly, especially the password dialog.  Use Motif!  If you don't
-have OSF Motif, use GNU Lesstif, it's free: http://www.lesstif.org/
-.TP 8
 .B SGI Power Saver
 If you're running Irix 6.3, you might find that your monitor is powering down
 after an hour or two even if you've told it not to.  This is fixed by SGI
@@ -1055,13 +1068,14 @@ of the \fBprograms\fP resource in the \fIConfiguration\fP section, above.)
 
 For example, on a screen that supports both 24-bit TrueColor and 12-bit
 PseudoColor visuals, the 12-bit visual will probably work best (this is true
-of base-model SGI Indys: the 0x29 visual is the one you want.)  Oddly, on 
-SGI O2s (machines that have serious hardware support for GL), the 12-bit
-PseudoColor visual looks awful (you get a black and white, flickery image.)
-On these machines, the visual you want turns out to be 0x31.  However, 0x31
-is but \fIone\fP of the \fIeight\fP 15-bit TrueColor visuals (yes, 8, and 
-yes, 15) that the O2 X server provides.  This is the only visual that works
-properly: as far as 
+of base-model SGI Indys: the 0x29 visual is the one you want.)  
+
+Oddly, on SGI O2s (machines that have serious hardware support for GL), the
+12-bit PseudoColor visual looks awful (you get a black and white, flickery
+image.)  On these machines, the visual you want turns out to be 0x31.
+However, 0x31 is but \fIone\fP of the \fIeight\fP 15-bit TrueColor visuals
+(yes, 8, and yes, 15) that the O2 X server provides.  This is the only visual
+that works properly: as far as
 .BR xdpyinfo (1)
 is concerned, all of the 15-bit TrueColor visuals are identical, but some
 flicker like mad, and some have deeply weird artifacts (such as hidden 
@@ -1072,6 +1086,45 @@ If anyone would care to explain it to me, that would be great.
 
 Your mileage, therefore, may vary dramatically.
 .TP 8
+.B MesaGL and Voodoo Cards
+If you have a 3Dfx/Voodoo card, the default settings for xscreensaver will run
+the GL-based graphics demos in such a way that they will not take advantage
+of the 3D acceleration hardware.  The solution is to change the \fBprograms\fP
+entries for the GL hacks from this:
+.EX
+    gears -root                       \\n\\
+.EE
+to this:
+.EX
+    MESA_GLX_FX=fullscreen  gears     \\n\\
+.EE
+That is, make sure that \fB$MESA_GLX_FX\fP is set to \fIfullscreen\fP, and
+don't tell the program to draw on the root window.  This may seem strange,
+but the setup used by Mesa and these kinds of cards \fIis\fP strange!
+
+For those who don't know, these cards work by sitting between your normal
+video card and the monitor, and seizing control of the monitor when it's 
+time to do 3D.  But this means that accelerated 3D only happens in full-screen
+mode (you can't do it in a window) and that 3D will probably drive your 
+monitor at a lower resolution, as well.  It's bizarre.
+.TP 8
+.B Extensions
+If you are not making use of one of the server extensions (\fBXIDLE\fP,
+\fBSGI SCREEN_SAVER\fP, or \fBMIT-SCREEN-SAVER\fP), then it is possible, in 
+rare situations, for \fIxscreensaver\fP to interfere with event propagation 
+and make another X program malfunction.  For this to occur, that other
+application would need to \fInot\fP select \fBKeyPress\fP events on its 
+non-leaf windows within the first 30 seconds of their existence, but then 
+select for them later.  In this case, that client \fImight\fP fail to receive 
+those events.  This isn't very likely, since programs generally select a
+constant set of events immediately after creating their windows and then 
+don't change them, but this is the reason that it's a good idea to install 
+and use one of the server extensions instead, to work around this shortcoming
+in the X protocol.
+
+In all these years, I've not heard of even a single case of this happening,
+but it is theoretically possible, so I'm mentioning it for completeness...
+.TP 8
 .B Red Hot Lava
 There need to be a lot more graphics hacks.  In particular, there should be
 a simulation of a Lavalite (tm).
@@ -1085,7 +1138,6 @@ of the screen on which to draw.
 .B PATH
 to find the sub-programs to run.
 .TP 8
-.TP 8
 .B HOME
 for the directory in which to read and write the \fI.xscreensaver\fP file.
 .TP 8
@@ -1097,6 +1149,7 @@ The latest version can always be found at
 http://www.jwz.org/xscreensaver/
 .SH SEE ALSO
 .BR X (1),
+.BR xscreensaver\-demo (1),
 .BR xscreensaver\-command (1),
 .BR xdm (1),
 .BR xset (1),
index 1e5cff499a67e6bc69d4d5ed79dfcf73667c204c..eea175c8472d0ac82221fcf930fccf6fe3dec03d 100644 (file)
@@ -137,13 +137,32 @@ init_sgi_saver_extension (saver_info *si)
 
 #endif /* HAVE_SGI_SAVER_EXTENSION */
 
+\f
+/* XIDLE server extension hackery.
+ */
+
+#ifdef HAVE_XIDLE_EXTENSION
+
+# include <X11/extensions/xidle.h>
+
+Bool
+query_xidle_extension (saver_info *si)
+{
+  int event_number;
+  int error_number;
+  return XidleQueryExtension (si->dpy, &event_number, &error_number);
+}
+
+#endif /* HAVE_XIDLE_EXTENSION */
+
+
 \f
 /* Figuring out what the appropriate XSetScreenSaver() parameters are
    (one wouldn't expect this to be rocket science.)
  */
 
 void
-disable_builtin_screensaver (saver_info *si, Bool turn_off_p)
+disable_builtin_screensaver (saver_info *si, Bool unblank_screen_p)
 {
   saver_preferences *p = &si->prefs;
   int current_server_timeout, current_server_interval;
@@ -173,10 +192,10 @@ disable_builtin_screensaver (saver_info *si, Bool turn_off_p)
   desired_server_interval = 0;
 
   /* I suspect (but am not sure) that DontAllowExposures might have
-     something to do with powering off the monitor as well. */
+     something to do with powering off the monitor as well, at least
+     on some systems that don't support XDPMS?  Who know... */
   desired_allow_exp = AllowExposures;
 
-#if defined(HAVE_MIT_SAVER_EXTENSION) || defined(HAVE_SGI_SAVER_EXTENSION)
   if (p->use_mit_saver_extension || p->use_sgi_saver_extension)
     {
       desired_server_timeout = (p->timeout / 1000);
@@ -189,8 +208,13 @@ disable_builtin_screensaver (saver_info *si, Bool turn_off_p)
        desired_prefer_blank = DontPreferBlanking;
     }
   else
-#endif /* HAVE_MIT_SAVER_EXTENSION || HAVE_SGI_SAVER_EXTENSION */
     {
+      /* When we're not using an extension, set the server-side timeout to 0,
+        so that the server never gets involved with screen blanking, and we
+        do it all ourselves.  (However, when we *are* using an extension,
+        we tell the server when to notify us, and rather than blanking the
+        screen, the server will send us an X event telling us to blank.)
+       */
       desired_server_timeout = 0;
     }
 
@@ -199,18 +223,17 @@ disable_builtin_screensaver (saver_info *si, Bool turn_off_p)
       desired_prefer_blank != current_prefer_blank ||
       desired_allow_exp != current_allow_exp)
     {
-      if (desired_server_timeout == 0)
+      if (unblank_screen_p)
        fprintf (stderr,
-                "%s%sisabling server builtin screensaver.\n"
-                "\tYou can re-enable it with \"xset s on\".\n",
-               (p->verbose_p ? "" : blurb()),
-               (p->verbose_p ? "\n\tD" : ": d"));
+                "%s disabling server builtin screensaver.\n"
+                "%s: you can re-enable it with \"xset s on\".\n",
+                blurb(), blurb());
 
       if (p->verbose_p)
-       fprintf (stderr, "%s: (xset s %d %d %s %s)\n", blurb(),
+       fprintf (stderr, "%s: (xset s %d %d; xset s %s; xset s %s)\n", blurb(),
                 desired_server_timeout, desired_server_interval,
                 (desired_prefer_blank ? "blank" : "noblank"),
-                (desired_allow_exp ? "noexpose" : "expose"));
+                (desired_allow_exp ? "expose" : "noexpose"));
 
       XSetScreenSaver (si->dpy,
                       desired_server_timeout, desired_server_interval,
@@ -235,7 +258,7 @@ disable_builtin_screensaver (saver_info *si, Bool turn_off_p)
   }
 #endif /* HAVE_MIT_SAVER_EXTENSION || HAVE_SGI_SAVER_EXTENSION */
 
-  if (turn_off_p)
+  if (unblank_screen_p)
     /* Turn off the server builtin saver if it is now running. */
     XForceScreenSaver (si->dpy, ScreenSaverReset);
 }
index a3b0a9cc5b18a9237dd3dcd19c3f1a32698ea346..3f3cd346fb69de8f803e41174e2ddbe5ac1963b2 100644 (file)
@@ -13,7 +13,6 @@
  * this version written by jwz, 4-Jun-98.
  *
  *   TODO:
- *      -  Should have a "macsbug" mode.
  *      -  Should simulate a Unix kernel panic and reboot.
  *      -  Making various boot noises would be fun, too.
  *      -  Maybe scatter some random bits across the screen,
@@ -182,7 +181,7 @@ bsod_sleep(Display *dpy, int seconds)
 }
 
 
-static void
+static Bool
 windows (Display *dpy, Window window, int delay, Bool w95p)
 {
   XGCValues gcv;
@@ -250,6 +249,9 @@ windows (Display *dpy, Window window, int delay, Bool w95p)
    "contact your system administrator or technical support group."
      );
 
+  if (!get_boolean_resource((w95p? "doWindows" : "doNT"), "DoWindows"))
+    return False;
+
   XGetWindowAttributes (dpy, window, &xgwa);
 
   fontname = get_string_resource ((xgwa.height > 600
@@ -294,12 +296,13 @@ windows (Display *dpy, Window window, int delay, Bool w95p)
   bsod_sleep(dpy, delay);
   XClearWindow(dpy, window);
   XFreeFont(dpy, font);
+  return True;
 }
 
 /* SCO OpenServer 5 panic, by Tom Kelly <tom@ancilla.toronto.on.ca>
  */
-static void
-openserver (Display *dpy, Window window, int delay)
+static Bool
+sco (Display *dpy, Window window, int delay)
 {
   XGCValues gcv;
   XWindowAttributes xgwa;
@@ -307,10 +310,11 @@ openserver (Display *dpy, Window window, int delay)
   const char *def_font = "fixed";
   XFontStruct *font;
   GC gc;
+  int lines = 1;
+  const char *s;
 
-  const char *openserver_panic =
-    ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
-     "Unexpected trap in kernel mode:\n"
+  const char *sco_panic =
+    ("Unexpected trap in kernel mode:\n"
      "\n"
      "cr0 0x80010013     cr2  0x00000014     cr3 0x00000000  tlb  0x00000000\n"
      "ss  0x00071054    uesp  0x00012055     efl 0x00080888  ipl  0x00000005\n"
@@ -330,13 +334,17 @@ openserver (Display *dpy, Window window, int delay)
      "** Press Any Key to Reboot **\n"
     );
 
+  if (!get_boolean_resource("doSCO", "DoSCO"))
+    return False;
+
+  for (s = sco_panic; *s; s++) if (*s == '\n') lines++;
 
   XGetWindowAttributes (dpy, window, &xgwa);
 
   fontname = get_string_resource ((xgwa.height > 600
-                                  ? "openserver.font2"
-                                  : "openserver.font"),
-                                 "OpenServer.Font");
+                                  ? "sco.font2"
+                                  : "sco.font"),
+                                 "SCO.Font");
   if (!fontname || !*fontname) fontname = (char *)def_font;
   font = XLoadQueryFont (dpy, fontname);
   if (!font) font = XLoadQueryFont (dpy, def_font);
@@ -345,11 +353,11 @@ openserver (Display *dpy, Window window, int delay)
     free (fontname);
 
   gcv.font = font->fid;
-  gcv.foreground = get_pixel_resource(("openserver.foreground"),
-                                     "OpenServer.Foreground",
+  gcv.foreground = get_pixel_resource(("sco.foreground"),
+                                     "SCO.Foreground",
                                      dpy, xgwa.colormap);
-  gcv.background = get_pixel_resource(("openserver.background"),
-                                     "OpenServer.Background",
+  gcv.background = get_pixel_resource(("sco.background"),
+                                     "SCO.Background",
                                      dpy, xgwa.colormap);
   XSetWindowBackground(dpy, window, gcv.background);
   XClearWindow(dpy, window);
@@ -357,18 +365,21 @@ openserver (Display *dpy, Window window, int delay)
   gc = XCreateGC(dpy, window, GCFont|GCForeground|GCBackground, &gcv);
 
   draw_string(dpy, window, gc, &gcv, font,
-               0, 0, xgwa.width, xgwa.height, openserver_panic, 0);
+             10, xgwa.height - (lines * (font->ascent + font->descent + 1)),
+             10, 10,
+             sco_panic, 0);
   XFreeGC(dpy, gc);
   XSync(dpy, False);
   bsod_sleep(dpy, delay);
   XClearWindow(dpy, window);
   XFreeFont(dpy, font);
+  return True;
 }
 
 
 /* Linux (sparc) panic, by Tom Kelly <tom@ancilla.toronto.on.ca>
  */
-static void
+static Bool
 sparc_linux (Display *dpy, Window window, int delay)
 {
   XGCValues gcv;
@@ -377,6 +388,8 @@ sparc_linux (Display *dpy, Window window, int delay)
   const char *def_font = "fixed";
   XFontStruct *font;
   GC gc;
+  int lines = 1;
+  const char *s;
 
   const char *linux_panic =
     ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
@@ -397,10 +410,13 @@ sparc_linux (Display *dpy, Window window, int delay)
        "l4: 0000ffff l5: f0131550 l6: f012c000 l7: f0130400\n"
        "i0: f1b13fb0 i1: 00000001 i2: 00000002 i3: 0007c000\n"
        "i4: f01457c0 i5: 00000004 i6: f1b13f70 i7: f0015360\n"
-       "Instruction DUMP:"
-
+       "Instruction DUMP:\n"
     );
 
+  if (!get_boolean_resource("doSparcLinux", "DoSparcLinux"))
+    return False;
+
+  for (s = linux_panic; *s; s++) if (*s == '\n') lines++;
 
   XGetWindowAttributes (dpy, window, &xgwa);
 
@@ -428,15 +444,18 @@ sparc_linux (Display *dpy, Window window, int delay)
   gc = XCreateGC(dpy, window, GCFont|GCForeground|GCBackground, &gcv);
 
   draw_string(dpy, window, gc, &gcv, font,
-               0, 0, xgwa.width, xgwa.height, linux_panic, 0);
+             10, xgwa.height - (lines * (font->ascent + font->descent + 1)),
+             10, 10,
+             linux_panic, 0);
   XFreeGC(dpy, gc);
   XSync(dpy, False);
   bsod_sleep(dpy, delay);
   XClearWindow(dpy, window);
   XFreeFont(dpy, font);
+  return True;
 }
 
-static void
+static Bool
 amiga (Display *dpy, Window window, int delay)
 {
   XGCValues gcv;
@@ -454,6 +473,9 @@ amiga (Display *dpy, Window window, int delay)
     ("_Software failure.  Press left mouse button to continue.\n"
      "_Guru Meditation #00000003.00C01570");
 
+  if (!get_boolean_resource("doAmiga", "DoAmiga"))
+    return False;
+
   XGetWindowAttributes (dpy, window, &xgwa);
 
   fontname = get_string_resource ((xgwa.height > 600
@@ -564,6 +586,7 @@ amiga (Display *dpy, Window window, int delay)
   XSync(dpy, False);
   XClearWindow(dpy, window);
   XFreeFont(dpy, font);
+  return True;
 }
 
 
@@ -577,7 +600,7 @@ amiga (Display *dpy, Window window, int delay)
        Perhaps somebody else can tell you more about it..  its just
        a quick hack :-}
  */
-static void
+static Bool
 atari (Display *dpy, Window window, int delay)
 {
        
@@ -589,9 +612,12 @@ atari (Display *dpy, Window window, int delay)
   Pixmap pixmap = 0;
   int pix_w = atari_width;
   int pix_h = atari_height;
-  int offset = atari_width + 2;
+  int offset;
   int i, x, y;
 
+  if (!get_boolean_resource("doAtari", "DoAtari"))
+    return False;
+
   XGetWindowAttributes (dpy, window, &xgwa);
 
   font = XLoadQueryFont (dpy, def_font);
@@ -609,11 +635,15 @@ atari (Display *dpy, Window window, int delay)
   gc = XCreateGC(dpy, window, GCFont|GCForeground|GCBackground, &gcv);
 
   pixmap = XCreatePixmapFromBitmapData(dpy, window, (char *) atari_bits,
-                                      atari_width, atari_height,
-                                      gcv.foreground,
-                                      gcv.background,
+                                      pix_w, pix_h,
+                                      gcv.foreground, gcv.background,
                                       xgwa.depth);
+  pixmap = double_pixmap(dpy, gc, xgwa.visual, xgwa.depth,
+                        pixmap, pix_w, pix_h);
+  pix_w *= 2;
+  pix_h *= 2;
 
+  offset = pix_w + 2;
   x = 5;
   y = (xgwa.height - (xgwa.height / 5));
   if (y < 0) y = 0;
@@ -635,10 +665,11 @@ atari (Display *dpy, Window window, int delay)
   bsod_sleep(dpy, delay);
   XClearWindow(dpy, window);
   XFreeFont(dpy, font);
+  return True;
 }
 
 
-static void
+static Bool
 mac (Display *dpy, Window window, int delay)
 {
   XGCValues gcv;
@@ -656,6 +687,9 @@ mac (Display *dpy, Window window, int delay)
   const char *string = ("0 0 0 0 0 0 0 F\n"
                        "0 0 0 0 0 0 0 3");
 
+  if (!get_boolean_resource("doMac", "DoMac"))
+    return False;
+
   XGetWindowAttributes (dpy, window, &xgwa);
 
   fontname = get_string_resource ("mac.font", "Mac.Font");
@@ -682,9 +716,6 @@ mac (Display *dpy, Window window, int delay)
                                       gcv.background,
                                       xgwa.depth);
 
-  draw_string(dpy, window, gc, &gcv, font, 0, 0,
-             xgwa.width, xgwa.height + offset, string, 0);
-
   for(i = 0; i < 2; i++)
     {
       pixmap = double_pixmap(dpy, gc, xgwa.visual, xgwa.depth,
@@ -702,14 +733,18 @@ mac (Display *dpy, Window window, int delay)
     XFreePixmap(dpy, pixmap);
   }
 
+  draw_string(dpy, window, gc, &gcv, font, 0, 0,
+             xgwa.width, xgwa.height + offset, string, 0);
+
   XFreeGC(dpy, gc);
   XSync(dpy, False);
   bsod_sleep(dpy, delay);
   XClearWindow(dpy, window);
   XFreeFont(dpy, font);
+  return True;
 }
 
-static void
+static Bool
 macsbug (Display *dpy, Window window, int delay)
 {
   XGCValues gcv;
@@ -820,6 +855,9 @@ macsbug (Display *dpy, Window window, int delay)
   const char *s;
   int body_lines = 1;
 
+  if (!get_boolean_resource("doMacsBug", "DoMacsBug"))
+    return False;
+
   for (s = body; *s; s++) if (*s == '\n') body_lines++;
 
   XGetWindowAttributes (dpy, window, &xgwa);
@@ -921,6 +959,7 @@ macsbug (Display *dpy, Window window, int delay)
   XFreeGC(dpy, gc2);
   XClearWindow(dpy, window);
   XFreeFont(dpy, font);
+  return True;
 }
 
 
@@ -928,40 +967,49 @@ macsbug (Display *dpy, Window window, int delay)
 char *progclass = "BSOD";
 
 char *defaults [] = {
-  "*delay:              30",
-
-  ".Windows.font:       -*-courier-bold-r-*-*-*-120-*-*-m-*-*-*",
-  ".Windows.font2:      -*-courier-bold-r-*-*-*-180-*-*-m-*-*-*",
-  ".Windows.foreground:         White",
-  ".Windows.background:         Blue",
-
-  ".Amiga.font:                 -*-courier-bold-r-*-*-*-120-*-*-m-*-*-*",
-  ".Amiga.font2:        -*-courier-bold-r-*-*-*-180-*-*-m-*-*-*",
-  ".Amiga.foreground:   Red",
-  ".Amiga.background:   Black",
-  ".Amiga.background2:  White",
-
-  ".Mac.font:           -*-courier-bold-r-*-*-*-120-*-*-m-*-*-*",
-  ".Mac.foreground:     PaleTurquoise1",
-  ".Mac.background:     Black",
-
-  ".Atari.foreground:   Black",
-  ".Atari.background:   White",
-
-  ".MacsBug.font:       -*-courier-medium-r-*-*-*-100-*-*-m-*-*-*",
-  ".MacsBug.font2:      -*-courier-bold-r-*-*-*-120-*-*-m-*-*-*",
-  ".MacsBug.font3:      -*-courier-bold-r-*-*-*-140-*-*-m-*-*-*",
-  ".MacsBug.foreground:         Black",
-  ".MacsBug.background:         White",
-  ".MacsBug.borderColor: #AAAAAA",
+  "*delay:                30",
+
+  "*doWindows:            True",
+  "*doNT:                 True",
+  "*doAmiga:              True",
+  "*doMac:                True",
+  "*doAtari:              False",      /* boring */
+  "*doMacsBug:            True",
+  "*doSCO:                True",
+  "*doSparcLinux:         False",      /* boring */
+
+  ".Windows.font:         -*-courier-bold-r-*-*-*-120-*-*-m-*-*-*",
+  ".Windows.font2:        -*-courier-bold-r-*-*-*-180-*-*-m-*-*-*",
+  ".Windows.foreground:           White",
+  ".Windows.background:           Blue",
+
+  ".Amiga.font:                   -*-courier-bold-r-*-*-*-120-*-*-m-*-*-*",
+  ".Amiga.font2:          -*-courier-bold-r-*-*-*-180-*-*-m-*-*-*",
+  ".Amiga.foreground:     Red",
+  ".Amiga.background:     Black",
+  ".Amiga.background2:    White",
+
+  ".Mac.font:             -*-courier-bold-r-*-*-*-120-*-*-m-*-*-*",
+  ".Mac.foreground:       PaleTurquoise1",
+  ".Mac.background:       Black",
+
+  ".Atari.foreground:     Black",
+  ".Atari.background:     White",
+
+  ".MacsBug.font:         -*-courier-medium-r-*-*-*-100-*-*-m-*-*-*",
+  ".MacsBug.font2:        -*-courier-bold-r-*-*-*-120-*-*-m-*-*-*",
+  ".MacsBug.font3:        -*-courier-bold-r-*-*-*-140-*-*-m-*-*-*",
+  ".MacsBug.foreground:           Black",
+  ".MacsBug.background:           White",
+  ".MacsBug.borderColor:   #AAAAAA",
   
-  ".OpenServer.font:    -*-courier-bold-r-*-*-*-120-*-*-m-*-*-*",
-  ".OpenServer.font2:   -*-courier-bold-r-*-*-*-140-*-*-m-*-*-*",
-  ".OpenServer.foreground: White",
-  ".OpenServer.background: Black",
+  ".SCO.font:             -*-courier-bold-r-*-*-*-120-*-*-m-*-*-*",
+  ".SCO.font2:            -*-courier-bold-r-*-*-*-140-*-*-m-*-*-*",
+  ".SCO.foreground:       White",
+  ".SCO.background:       Black",
   
-  ".SparcLinux.font:    -*-courier-bold-r-*-*-*-120-*-*-m-*-*-*",
-  ".SparcLinux.font2:   -*-courier-bold-r-*-*-*-140-*-*-m-*-*-*",
+  ".SparcLinux.font:      -*-courier-bold-r-*-*-*-120-*-*-m-*-*-*",
+  ".SparcLinux.font2:     -*-courier-bold-r-*-*-*-140-*-*-m-*-*-*",
   ".SparcLinux.foreground: White",
   ".SparcLinux.background: Black",
   0
@@ -972,9 +1020,11 @@ XrmOptionDescRec options [] = {
   { 0, 0, 0, 0 }
 };
 
+
 void
 screenhack (Display *dpy, Window window)
 {
+  int loop = 0;
   int i = -1;
   int j = -1;
   int delay = get_integer_resource ("delay", "Integer");
@@ -985,21 +1035,26 @@ screenhack (Display *dpy, Window window)
 
   while (1)
     {
-      while (i == j) i = random() % 8;
-      j = i;
-
+      Bool did;
+      do {  i = (random() & 0xFF) % 8; } while (i == j);
       switch (i)
        {
-       case 0: windows(dpy, window, delay, True); break;
-       case 1: windows(dpy, window, delay, False); break;
-       case 2: amiga(dpy, window, delay); break;
-       case 3: mac(dpy, window, delay); break;
-       case 4: macsbug(dpy, window, delay); break;
-       case 5: openserver(dpy, window, delay); break;
-       case 6: sparc_linux(dpy, window, delay); break;
-       case 7: atari(dpy, window, delay); break;
+       case 0: did = windows(dpy, window, delay, True); break;
+       case 1: did = windows(dpy, window, delay, False); break;
+       case 2: did = amiga(dpy, window, delay); break;
+       case 3: did = mac(dpy, window, delay); break;
+       case 4: did = macsbug(dpy, window, delay); break;
+       case 5: did = sco(dpy, window, delay); break;
+       case 6: did = sparc_linux(dpy, window, delay); break;
+       case 7: did = atari(dpy, window, delay); break;
        default: abort(); break;
        }
+      loop++;
+      if (loop > 100) j = -1;
+      if (loop > 200) exit(-1);
+      if (!did) continue;
       XSync (dpy, True);
+      j = i;
+      loop = 0;
     }
 }
index 4a0bdc8e0477c7e53a29471d195a2d5b7a4cb217..7eed6281c8b9c4d3ecef180c77956506ae080fd9 100644 (file)
@@ -57,6 +57,9 @@ static void move_lense(int);
 static void swamp_thing(int);
 static void new_rnd_coo(int);
 static void init_round_lense(void);
+static void (*draw) (int) = NULL;
+static void reflect_draw(int);
+static void plain_draw(int);
 
 static void init_distort(Display *dpy, Window window) 
 {
@@ -67,10 +70,10 @@ static void init_distort(Display *dpy, Window window)
        g_window=window;
        g_dpy=dpy;
 
-       delay = get_integer_resource ("delay", "Integer");
-       radius = get_integer_resource ("radius", "Integer");
-       speed = get_integer_resource ("speed", "Integer");
-       number = get_integer_resource ("number", "Integer");
+       delay = get_integer_resource("delay", "Integer");
+       radius = get_integer_resource("radius", "Integer");
+       speed = get_integer_resource("speed", "Integer");
+       number = get_integer_resource("number", "Integer");
 
 #ifdef HAVE_XSHM_EXTENSION
        use_shm = get_boolean_resource("useSHM", "Boolean");
@@ -81,9 +84,9 @@ static void init_distort(Display *dpy, Window window)
        magnify = get_boolean_resource("magnify", "Boolean");
        reflect = get_boolean_resource("reflect", "Boolean");
        
-       if (get_boolean_resource ("swamp", "Boolean"))
+       if (get_boolean_resource("swamp", "Boolean"))
                effect = &swamp_thing;
-       if (get_boolean_resource ("bounce", "Boolean") || reflect)
+       if (get_boolean_resource("bounce", "Boolean"))
                effect = &move_lense;
 
        if (effect == NULL && radius == 0 && speed == 0 && number == 0
@@ -104,9 +107,13 @@ static void init_distort(Display *dpy, Window window)
  * -radius 50 -number 4 -speed 2 -swamp -vortex
  * -radius 50 -number 4 -speed 2 -swamp -vortex -magnify
  * -radius 50 -number 4 -speed 2 -swamp -vortex -magnify -blackhole
+ * -radius 80 -number 1 -speed 2 -reflect
+ * -radius 50 -number 3 -speed 2 -reflect
  */
                
-               i = (random() % 15);
+               i = (random() % 17);
+
+               draw = &plain_draw;
 
                switch (i) {
                        case 0:
@@ -151,9 +158,15 @@ static void init_distort(Display *dpy, Window window)
                        case 13:
                                radius=50;number=4;speed=2;vortex=1;magnify=1;
                                effect=&swamp_thing;break;
-                       case 14: default:
+                       case 14:
                                radius=50;number=4;speed=2;vortex=1;magnify=1;blackhole=1;
                                effect=&swamp_thing;break;
+                       case 15:
+                               radius=80;number=1;speed=2;reflect=1;
+                               draw = &reflect_draw;effect = &move_lense;break;
+                       case 16: default:
+                               radius=50;number=4;speed=2;reflect=1;
+                               draw = &reflect_draw;effect = &move_lense;break;
                }
 
        }
@@ -170,6 +183,12 @@ static void init_distort(Display *dpy, Window window)
                number=1;
        if (effect == NULL)
                effect = &move_lense;
+       if (reflect) {
+               draw = &reflect_draw;
+               effect = &move_lense;
+       }
+       if (draw == NULL)
+               draw = &plain_draw;
 
        XGetWindowAttributes (dpy, window, &xgwa);
        black_pixel = BlackPixelOfScreen( xgwa.screen );
@@ -243,7 +262,6 @@ static void init_distort(Display *dpy, Window window)
 static void make_round_lense(int radius, int loop)
 {
        int i, j;
-       double theta;
 
        for (i = 0; i < 2*radius+speed+2; i++) {
                for(j = 0; j < 2*radius+speed+2; j++) {
@@ -265,17 +283,16 @@ static void make_round_lense(int radius, int loop)
                /* 2.5 is just a constant used because it looks good :) */
                                        angle = 2.5*(1-d)*(1-d);
 
-
         /* Avoid atan2: DOMAIN error message */
-        if ((radius-j) == 0.0 && (radius-i) == 0.0)
-            theta = 0.0;
-        else
-            theta = atan2(radius-j, radius-i);
-        from[i][j][0] = radius +
-                        cos(angle - theta)*r;
-        from[i][j][1] = radius +
-                        sin(angle - theta)*r;
-
+                                       if ((radius-j) == 0.0 && (radius-i) == 0.0) {
+                                               from[i][j][0] = radius + cos(angle)*r;
+                                               from[i][j][1] = radius + sin(angle)*r;
+                                       } else {
+                                       from[i][j][0] = radius +
+                                                                       cos(angle - atan2(radius-j, -(radius-i)))*r;
+                                       from[i][j][1] = radius +
+                                                                       sin(angle - atan2(radius-j, -(radius-i)))*r;
+                                       }
                                        if (magnify) {
                                                r = sin(d*M_PI_2);
                                                if (blackhole && r != 0) /* blackhole effect */
@@ -290,7 +307,7 @@ static void make_round_lense(int radius, int loop)
         * distortion, a negative value sucks everything into a black hole
         */
                                /*      r = r*r; */
-                                       if (blackhole) /* blackhole effect */
+                                       if (blackhole && r != 0) /* blackhole effect */
                                                r = 1/r;
                                                                        /* bubble effect (and blackhole) */
                                        from[i][j][0] = radius + (i-radius)*r;
@@ -360,53 +377,67 @@ static void init_round_lense(void)
 
 
 /* generate an XImage of from[][][] and draw it on the screen */
-void draw(int k)
+void plain_draw(int k)
+{
+       int i, j;
+       for(i = 0 ; i < 2*radius+speed+2; i++) {
+               for(j = 0 ; j < 2*radius+speed+2 ; j++) {
+                       if (xy_coo[k].x+from[i][j][0] >= 0 &&
+                                       xy_coo[k].x+from[i][j][0] < xgwa.width &&
+                                       xy_coo[k].y+from[i][j][1] >= 0 &&
+                                       xy_coo[k].y+from[i][j][1] < xgwa.height)
+                               XPutPixel(buffer_map, i, j,
+                                               XGetPixel(orig_map,
+                                                       xy_coo[k].x+from[i][j][0],
+                                                       xy_coo[k].y+from[i][j][1]));
+               }
+       }
+
+       XPutImage(g_dpy, g_window, gc, buffer_map, 0, 0, xy_coo[k].x, xy_coo[k].y,
+                       2*radius+speed+2, 2*radius+speed+2);
+}
+
+/* generate an XImage from the reflect algoritm submitted by
+ * Randy Zack <randy@acucorp.com>
+ * draw really got too big and ugly so I split it up
+ * it should be possible to use the from[][] to speed it up
+ * (once I figure out the algorithm used :)
+ */
+void reflect_draw(int k)
 {
        int i, j;
        int     cx, cy;
        int     ly, lysq, lx, ny, dist, rsq = radius * radius;
-       if (reflect) {
-               cx = cy = radius;
-               if (xy_coo[k].ymove > 0)
-                       cy += speed;
-               if (xy_coo[k].xmove > 0)
-                       cx += speed;
-       }
+
+       cx = cy = radius;
+       if (xy_coo[k].ymove > 0)
+               cy += speed;
+       if (xy_coo[k].xmove > 0)
+               cx += speed;
+
        for(i = 0 ; i < 2*radius+speed+2; i++) {
-               if (reflect) {
-                       ly = i - cy;
-                       lysq = ly * ly;
-                       ny = xy_coo[k].y + i;
-               }
+               ly = i - cy;
+               lysq = ly * ly;
+               ny = xy_coo[k].y + i;
                for(j = 0 ; j < 2*radius+speed+2 ; j++) {
-                       if (reflect) {
-                               lx = j - cx;
-                               dist = lx * lx + lysq;
-                               if (dist > rsq ||
-                                       ly < -radius || ly > radius ||
-                                       lx < -radius || lx > radius)
-                                       XPutPixel( buffer_map, j, i,
-                                                          XGetPixel( orig_map, xy_coo[k].x + j, ny ));
-                               else if (dist == 0)
+                       lx = j - cx;
+                       dist = lx * lx + lysq;
+                       if (dist > rsq ||
+                               ly < -radius || ly > radius ||
+                               lx < -radius || lx > radius)
+                               XPutPixel( buffer_map, j, i,
+                                                  XGetPixel( orig_map, xy_coo[k].x + j, ny ));
+                       else if (dist == 0)
+                               XPutPixel( buffer_map, j, i, black_pixel );
+                       else {
+                               int     x = xy_coo[k].x + cx + (lx * rsq / dist);
+                               int     y = xy_coo[k].y + cy + (ly * rsq / dist);
+                               if (x < 0 || x > xgwa.width ||
+                                       y < 0 || y > xgwa.height)
                                        XPutPixel( buffer_map, j, i, black_pixel );
-                               else {
-                                       int     x = xy_coo[k].x + cx + (lx * rsq / dist);
-                                       int     y = xy_coo[k].y + cy + (ly * rsq / dist);
-                                       if (x < 0 || x > xgwa.width ||
-                                               y < 0 || y > xgwa.height)
-                                               XPutPixel( buffer_map, j, i, black_pixel );
-                                       else
-                                               XPutPixel( buffer_map, j, i,
-                                                                  XGetPixel( orig_map, x, y ));
-                               }
-                       } else if (xy_coo[k].x+from[i][j][0] >= 0 &&
-                                          xy_coo[k].x+from[i][j][0] < xgwa.width &&
-                                          xy_coo[k].y+from[i][j][1] >= 0 &&
-                                          xy_coo[k].y+from[i][j][1] < xgwa.height) {
-                               XPutPixel(buffer_map, i, j,
-                                                 XGetPixel(orig_map,
-                                                                       xy_coo[k].x+from[i][j][0],
-                                                                       xy_coo[k].y+from[i][j][1]));
+                               else
+                                       XPutPixel( buffer_map, j, i,
+                                                          XGetPixel( orig_map, x, y ));
                        }
                }
        }
@@ -458,7 +489,7 @@ static void move_lense(int k)
        for (i = 0; i < number; i++) {
                if ((i != k)
                
-/* This commented test is for rectangular lenses (not presently used) and
+/* This commented test is for rectangular lenses (not currently used) and
  * the one used is for circular ones
                && (abs(xy_coo[k].x - xy_coo[i].x) <= 2*radius)
                && (abs(xy_coo[k].y - xy_coo[i].y) <= 2*radius)) { */
index 3b8a7d24d995989efc90414034aa4ed62e9ab286..57c2aa454661aba448c7ba31b49e0b2a2bae30eb 100644 (file)
@@ -1,13 +1,6 @@
-#define atari_width 34
-#define atari_height 28
+#define atari_width 17
+#define atari_height 14
 static char atari_bits[] = {
- 0x00,0x0f,0x00,0x00,0xfc,0x00,0x0f,0x00,0x00,0xfc,0xcc,0x30,0x00,0x00,0xfc,
- 0xcc,0x30,0x00,0x00,0xfc,0x00,0xc0,0x00,0x00,0xfc,0x00,0xc0,0x00,0x00,0xfc,
- 0xc3,0x00,0x03,0x00,0xfc,0xc3,0x00,0x03,0x00,0xfc,0x30,0xf0,0x3f,0x00,0xfc,
- 0x30,0xf0,0x3f,0x00,0xfc,0x00,0xf0,0x3f,0x00,0xfc,0x00,0xf0,0x3f,0x00,0xfc,
- 0x00,0xff,0xff,0x03,0xfc,0x00,0xff,0xff,0x03,0xfc,0xc0,0xff,0xff,0x0f,0xfc,
- 0xc0,0xff,0xff,0x0f,0xfc,0xc0,0xf3,0xff,0x0f,0xfc,0xc0,0xf3,0xff,0x0f,0xfc,
- 0xf0,0xff,0xff,0x3f,0xfc,0xf0,0xff,0xff,0x3f,0xfc,0xf0,0xff,0xcf,0x3f,0xfc,
- 0xf0,0xff,0xcf,0x3f,0xfc,0xc0,0xff,0xcf,0x0f,0xfc,0xc0,0xff,0xcf,0x0f,0xfc,
- 0xc0,0xff,0xf3,0x0f,0xfc,0xc0,0xff,0xf7,0x0f,0xfc,0x00,0xff,0xff,0x03,0xfc,
- 0x00,0xff,0xff,0x03,0xfc};
+ 0x30,0x00,0x00,0x4a,0x00,0x00,0x80,0x00,0x00,0x09,0x01,0x00,0xc4,0x07,0x00,
+ 0xc0,0x07,0x00,0xf0,0x1f,0x00,0xf8,0x3f,0x00,0xd8,0x3f,0x00,0xfc,0x7f,0x00,
+ 0xfc,0x7b,0x00,0xf8,0x3b,0x00,0xf8,0x3d,0x00,0xf0,0x1f,0x00};
index 68d94013aa514941112b14d60be6a5ef18ccff0c..604c2b66ef0331ff47051a8dbd2340266a293dfd 100644 (file)
@@ -1,2 +1,2 @@
 static const char screensaver_id[] =
-       "@(#)xscreensaver 2.34 (08-Oct-98), by Jamie Zawinski (jwz@jwz.org)";
+       "@(#)xscreensaver 3.01 (24-Oct-98), by Jamie Zawinski (jwz@jwz.org)";
index 50302eca62a743c11d97953588f17f1e229d1106..241b03a7951987c656e2378fd6192b3f6bf756c8 100644 (file)
@@ -1,22 +1,25 @@
 Begin3
 Title:          xscreensaver
-Version:        2.34
-Entered-date:   08OCT98
+Version:        3.01
+Entered-date:   24OCT98
 Description:    A modular screen saver and locker for the X Window System.
                 Highly customizable: allows the use of any program that
                 can draw on the root window as a display mode.
                 Comes with more than 80 display modes.
-                Home page: http://www.jwz.org/xscreensaver/
 Keywords:       screen saver, screen lock, lock, xlock, X11
 Author:         jwz@jwz.org (Jamie Zawinski)
 Maintained-by:  jwz@jwz.org (Jamie Zawinski)
-Primary-site:   ftp.x.org /contrib/applications/
-                927K xscreensaver-2.34.tar.gz
-                22K  xscreensaver.README
+Primary-site:   http://www.jwz.org/xscreensaver/
+                957K xscreensaver-3.01.tar.gz
+                24K  xscreensaver.README
                 1K   xscreensaver.lsm
 Alternate-site: sunsite.unc.edu /pub/Linux/X11/screensavers/
-                927K xscreensaver-2.34.tar.gz
-                22K  xscreensaver.README
+                957K xscreensaver-3.01.tar.gz
+                24K  xscreensaver.README
+                1K   xscreensaver.lsm
+Alternate-site: ftp.x.org /contrib/applications/
+                957K xscreensaver-3.01.tar.gz
+                24K  xscreensaver.README
                 1K   xscreensaver.lsm
 Platforms:      Linux, Irix, SunOS, Solaris, HPUX, AIX, FreeBSD, NetBSD,
                 BSDI, SCO, OSF1, Ultrix, VMS.
index 52bf0a5c1afa0608c68fe3d723c2d780723458a7..d5a0d3d15ef601aad9863b11082c9c4c9f5a724f 100755 (executable)
@@ -29,11 +29,10 @@ Description:    A modular screen saver and locker for the X Window System.
                 Highly customizable: allows the use of any program that
                 can draw on the root window as a display mode.
                 Comes with more than 80 display modes.
-                Home page: http://www.jwz.org/xscreensaver/
 Keywords:       screen saver, screen lock, lock, xlock, X11
 Author:         jwz@jwz.org (Jamie Zawinski)
 Maintained-by:  jwz@jwz.org (Jamie Zawinski)
-Primary-site:   ftp.x.org /contrib/applications/
+Primary-site:   http://www.jwz.org/xscreensaver/
                 $TAR_SIZE xscreensaver-$VERSION.tar.gz
                 $README_SIZE  xscreensaver.README
                 $LSM_SIZE   xscreensaver.lsm
@@ -41,6 +40,10 @@ Alternate-site: sunsite.unc.edu /pub/Linux/X11/screensavers/
                 $TAR_SIZE xscreensaver-$VERSION.tar.gz
                 $README_SIZE  xscreensaver.README
                 $LSM_SIZE   xscreensaver.lsm
+Alternate-site: ftp.x.org /contrib/applications/
+                $TAR_SIZE xscreensaver-$VERSION.tar.gz
+                $README_SIZE  xscreensaver.README
+                $LSM_SIZE   xscreensaver.lsm
 Platforms:      Linux, Irix, SunOS, Solaris, HPUX, AIX, FreeBSD, NetBSD,
                 BSDI, SCO, OSF1, Ultrix, VMS.
                 Requires X11 and ANSI C.