http://www.ibiblio.org/pub/historic-linux/ftp-archives/sunsite.unc.edu/Sep-29-1996...
authorZygo Blaxell <zblaxell@hungrycats.org>
Mon, 2 Mar 2009 05:42:20 +0000 (00:42 -0500)
committerZygo Blaxell <zblaxell@hungrycats.org>
Mon, 2 Mar 2009 05:42:20 +0000 (00:42 -0500)
-rw-r--r-- 1 zblaxell zblaxell 148692 May 24  2002 xscreensaver-1.26.tar.gz
e06b9602a89be6f08963e6a0f933b1edeae68eb4  xscreensaver-1.26.tar.gz

70 files changed:
README
config.h
driver/Imakefile
driver/XScreenSaver.ad
driver/demo.c
driver/dialogs.c
driver/dialogs.xd
driver/lock.c
driver/stderr.c
driver/subprocs.c
driver/timers.c
driver/windows.c
driver/xscreensaver-command.c
driver/xscreensaver-command.man
driver/xscreensaver.c
driver/xscreensaver.h
driver/xscreensaver.man
hacks/Imakefile
hacks/attraction.c
hacks/attraction.man
hacks/blitspin.c
hacks/blitspin.man
hacks/decayscreen.c
hacks/flame.c
hacks/flame.man
hacks/greynetic.c
hacks/greynetic.man
hacks/halo.c
hacks/halo.man
hacks/helix.c
hacks/helix.man
hacks/hopalong.c
hacks/hopalong.man
hacks/hypercube.c
hacks/hypercube.man
hacks/imsmap.c
hacks/imsmap.man
hacks/lmorph.c [new file with mode: 0644]
hacks/lmorph.man [new file with mode: 0644]
hacks/maze.c
hacks/noseguy.c
hacks/noseguy.man
hacks/noses/CVS/Entries
hacks/pedal.c
hacks/pyro.c
hacks/pyro.man
hacks/qix.c
hacks/qix.man
hacks/rocks.c
hacks/rocks.man
hacks/rorschach.c
hacks/rorschach.man
hacks/screenhack.c
hacks/screenhack.h
hacks/slidescreen.c
hacks/slidescreen.man
hacks/xlock.h
hacks/xroger-hack.c
hacks/xroger.man
utils/Imakefile
utils/fade.c
utils/grabscreen.c
utils/hsv.c
utils/resources.c
utils/usleep.c
utils/version.h
utils/visual.c
utils/xroger.c
utils/yarandom.c [new file with mode: 0644]
utils/yarandom.h [new file with mode: 0644]

diff --git a/README b/README
index 8470574bf8774dedf9a4023ae6851c669891a4cb..55b1ae208d46845fbca13a34719f6222fc238c38 100644 (file)
--- a/README
+++ b/README
@@ -26,8 +26,7 @@ now be used as a screensaver without modification.  The programs that
 are being run as screensavers don't need to have any special knowledge
 about what it means to be a screensaver.
 
-The XIDLE or MIT-SCREEN-SAVER server extensions will be used if you have
-them (win win.)
+The XIDLE or MIT-SCREEN-SAVER server extensions will be used if you have them.
 
 Unfortunately, locking doesn't work if you don't have Motif.
 
@@ -57,6 +56,7 @@ window, which are pointed at by the screensaver's default resource settings.
                  things.  I snarfed this code from xnlock.
    maze                - This is the X maze demo modified to take a -root option
                  so that it works with xscreensaver.
+   lmorph      - morphing line drawings.
 
 All of these will pop up their own window unless given that -root option.
 See their man pages for more details.
@@ -77,16 +77,20 @@ You can get all of these from the contrib directory on ftp.x.org.  If you
 know of (or write) any other interesting programs that can be used as
 screensavers, please let me know!
 
-This program should be updated to take advantage of the new R6 `screensaver'
-server extension instead of XIdle.  I didn't have time to do this before the
-deadline for the R6 contrib tape, but by the time you read this, maybe it's
-done - check a later release.
+The latest version of xscreensaver is always ftpable from ftp.x.org.  You can
+also get it from my web page at http://www.netscape.com/people/jwz/.
 
-The latest version of xscreensaver is on FTP.X.ORG.
-
-       -- Jamie Zawinski <jwz@mcom.com>
+       -- Jamie Zawinski <jwz@netscape.com>
 
 \f
+Changes since 1.25:    Added `lmorph' hack.
+                       Added viscosity and mouse-control to attraction.
+                       Fixed possible bad color choices in qix and attraction.
+                       Added ramp-mode to halo.
+                       Added a new RNG, which is faster and more portable
+                       than using the RNG in libc.
+                       Made locking work on SCO.
+                       Various other minor tweaks that I don't remember.
 Changes since 1.24:    Made it capture the stdout/stderr of its subprocesses
                        and present them on the screensaver window itself.
                        Made demo mode work correctly with non-default visuals
index 02ca5f4c3ee4edf330385b635d66fa4388580b4f..17517dc801f3f5a2da4cc2c635bd5be9a6d81355 100644 (file)
--- a/config.h
+++ b/config.h
@@ -3,15 +3,6 @@
  * This file is included by the various Imakefiles.
  */
 
-/*  Uncomment the following line if you have the MIT-SCREEN-SAVER extension
- *  installed.  This extension resides in .../contrib/extensions/screensaver/
- *  on the X11R6 contrib tape.  (Turning on this flag lets XScreenSaver work
- *  better with servers which support this extension; but it will still work
- *  with servers which do not suport this extension, so it's a good idea to
- *  compile in support for it if you can.)
- */
-/* #define HAVE_SAVER_EXTENSION */
-
 /*  Uncomment the following line if you have the XIDLE extension installed.
  *  This extension resides in .../contrib/extensions/xidle/ on the X11R5
  *  contrib tape.  (Turning on this flag lets XScreenSaver work better with
  */
 /* #define HAVE_XIDLE_EXTENSION */
 
+/*  Uncomment the following line if you have the MIT-SCREEN-SAVER extension
+ *  installed.  This extension resides in .../contrib/extensions/screensaver/
+ *  on the X11R6 contrib tape.
+ *
+ *  This extension does basically the same thing that the XIDLE extension does,
+ *  but there are two things wrong with it: first, because of the way the 
+ *  extension was designed, the `fade' option to XScreenSaver will be uglier:
+ *  just before the screen fades out, there will be an unattractive flicker to
+ *  black, because this extension blanks the screen *before* telling us that it
+ *  is time to do so.  Second, this extension is known to be buggy; on the
+ *  systems I use, it works, but some people have reported X server crashes as
+ *  a result of using it.  XScreenSaver uses this extension rather
+ *  conservatively, because when I tried to use any of its more complicated
+ *  features, I could get it to crash the server at the drop of a hat.
+ *
+ *  I wish someone would port the XIDLE extension to R6.  Or I wish someone
+ *  would make the MIT-SCREEN-SAVER extension not be such a piece of junk.
+ *
+ *  Note that the SGI X server also has an extension called SCREEN_SAVER.
+ *  That is a completely different extension, and XScreenSaver contains no
+ *  support for it (though it probably wouldn't be hard.)
+ */
+/* #define HAVE_SAVER_EXTENSION */
+
 /*  Uncomment the following line if you have the XPM library installed.
  *  Some of the demos can make use of this if it is available.
  */
index 0caccaf3174e863cc7b0f75d7f568bd3323287ba..5444939a938163186e2e0a19cf06dbfd1c44588b 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "../config.h"
 
+/* #### If anyone ever finishes the Athena locking code, remove this. */
 #if defined(NO_MOTIF) && !defined(NO_LOCKING)
 # define NO_LOCKING
 #endif
        DEFINES = SETUID_DEF XIDLE_DEF SAVER_DEF MOTIF_DEF LOCKING_DEF SHADOW_DEF R5ISMS
      SAVERLIBS = $(XMULIB) $(XTOOLLIB) $(EXTENSIONLIB) $(XLIB) -lm
       COMMLIBS = $(XLIB) -lm
-     UTIL_SRCS = $(UTILS)/resources.c $(UTILS)/fade.c $(UTILS)/usleep.c $(UTILS)/visual.c
-     UTIL_OBJS = $(UTILS)/resources.o $(UTILS)/fade.o $(UTILS)/usleep.o $(UTILS)/visual.o
-     DBOX_SRCS = dialogs.c demo.c lock.c
-     DBOX_OBJS = dialogs.o demo.o lock.o
+     UTIL_SRCS = $(UTILS)/resources.c $(UTILS)/fade.c $(UTILS)/visual.c $(UTILS)/usleep.c $(UTILS)/yarandom.c
+     UTIL_OBJS = $(UTILS)/resources.o $(UTILS)/fade.o $(UTILS)/visual.o $(UTILS)/usleep.o $(UTILS)/yarandom.o
+     DBOX_SRCS = dialogs.c demo.c
+     DBOX_OBJS = dialogs.o demo.o
+     LOCK_SRCS = lock.c
+     LOCK_OBJS = lock.o
      SAVERSRCS = xscreensaver.c timers.c subprocs.c windows.c stderr.c
      SAVEROBJS = xscreensaver.o timers.o subprocs.o windows.o stderr.o
-         SRCS1 = $(SAVERSRCS) MOTIF_SRC $(UTIL_SRCS)
-         OBJS1 = $(SAVEROBJS) MOTIF_OBJ $(UTIL_OBJS)
+         SRCS1 = $(SAVERSRCS) MOTIF_SRC $(LOCK_SRCS) $(UTIL_SRCS)
+         OBJS1 = $(SAVEROBJS) MOTIF_OBJ $(LOCK_OBJS) $(UTIL_OBJS)
       COMMSRCS = xscreensaver-command.c
       COMMOBJS = xscreensaver-command.o
          SRCS2 = $(COMMSRCS)
          OBJS2 = $(COMMOBJS)
            MEN = xscreensaver.man xscreensaver-command.man
-      TARFILES = README Imakefile $(SAVERSRCS) $(DBOX_SRCS) $(COMMSRCS) \
-                 xscreensaver.h XScreenSaver.ad dialogs.xd $(MEN) .gdbinit
+      TARFILES = README Imakefile $(SAVERSRCS) $(DBOX_SRCS) $(LOCK_SRCS) \
+                 $(COMMSRCS) xscreensaver.h XScreenSaver.ad dialogs.xd \
+                 $(MEN) .gdbinit
 
 #if defined(HPArchitecture) && !defined(NO_LOCKING)
 EXTRA_LIBRARIES = -lXhp11      /* for XHPDisableReset() */
 #endif
 
+#if defined(i386ScoArchitecture)
+        SCOLIBS = -lintl -lprot -lx -lcrypt_i
+#endif
+
 all:: xscreensaver xscreensaver-command
 
 echo_tarfiles:
@@ -96,7 +104,7 @@ PROGRAMS = xscreensaver xscreensaver-command
 #define InstallProgram(p,d) InstallProgramWithFlags(p,d,$(INSTUIDFLAGS))
 #endif
 
-ComplexProgramTarget_1(xscreensaver,MOTIF_LIB $(SAVERLIBS),$(HP_NULL_STR))
+ComplexProgramTarget_1(xscreensaver,MOTIF_LIB $(SAVERLIBS),$(SCOLIBS) $(HP_NULL_STR))
 
 #ifdef INSTALL_SETUID
 #undef  InstallProgram
@@ -121,3 +129,24 @@ XScreenSaver.ad.h: XScreenSaver.ad
 
 clean::
        $(RM) XScreenSaver.ad.h
+
+
+#if defined(SparcArchitecture) || defined(SGIArchitecture)
+# undef  UsePurify
+# define UsePurify
+#endif
+
+#ifdef UsePurify
+        PURIFY = purify
+ PURIFYOPTIONS = 
+
+# undef  PurifyProgramTarget
+# define PurifyProgramTarget(program,deplist,linklist)                 @@\
+program.pure: deplist                                                  @@\
+       RemoveTargetProgram($@)                                         @@\
+       $(CCENVSETUP) $(PURIFY) $(PURIFYOPTIONS) $(CC)                    \
+         -o $@ $(LDOPTIONS) linklist $(EXTRA_LOAD_FLAGS)
+
+PurifyProgramTarget(xscreensaver,$(OBJS1),$(OBJS1) MOTIF_LIB $(SAVERLIBS))
+
+#endif /* Purify */
index 0c3656ba2cdaad2aea9150472a334f5443c9dcdf..da72eff8906e5a31f88adb1c6ee18eae28714bd2 100644 (file)
@@ -45,7 +45,8 @@
                hypercube -root                                         \n\
                halo -root                                              \n\
                maze -root                                              \n\
-               flame -root                                             \n
+               flame -root                                             \n\
+               lmorph -root                                            \n
 
 ! Programs on this list are run only for monochrome screens.
 *monoPrograms: qix -root -linear -count 5 -size 200 -spread 30         \
 *demoDialog.maxWidth:          600
 
 *label1.labelString:           XScreenSaver %s
-*label2.labelString: Copyright Â© 1991-1995 by Jamie Zawinski <jwz@mcom.com>
+*label2.labelString: Copyright Â© 1991-1995 by Jamie Zawinski <jwz@netscape.com>
 *demoList.visibleItemCount:    10
 *demoList.automaticSelection:  True
 *next.labelString:             Run Next
index 64bd58bc27bda24b0bcf3cc03840de4204e1d673..b7823400dd5d200c4bd09d589049f2632cb7e7ef 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1993-1995 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1993-1995 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
index b4612b5d2f126949b6bd8c371064163f2c3e18d0..a403c1b81f796dfb70255341e67988f687838c6b 100644 (file)
@@ -73,19 +73,13 @@ Widget restart;
 Widget spacer;
 
 
+void
 create_passwd_dialog( parent )
 Widget parent;
 {
-       Display *display = XtDisplay ( parent );
        Widget children[8];      /* Children to manage */
        Arg al[64];           /* Arg List */
        register int ac = 0;      /* Arg Count */
-       char from_s [256];    /* For font list conversion */
-       XrmValue from_value, to_value; /* ditto */
-       int fg, bg;           /* colour values for pixmaps */ 
-       XmString *list_items; /* For list items */
-       int list_item;        /* Index for list_items */
-       XmString xmstrings[15];    /* temporary storage for XmStrings */
        Widget widget4;
        Widget widget7;
 
@@ -216,19 +210,13 @@ Widget parent;
 
 
 
+void
 create_resources_dialog( parent )
 Widget parent;
 {
-       Display *display = XtDisplay ( parent );
        Widget children[22];      /* Children to manage */
        Arg al[64];           /* Arg List */
        register int ac = 0;      /* Arg Count */
-       char from_s [256];    /* For font list conversion */
-       XrmValue from_value, to_value; /* ditto */
-       int fg, bg;           /* colour values for pixmaps */ 
-       XmString *list_items; /* For list items */
-       int list_item;        /* Index for list_items */
-       XmString xmstrings[15];    /* temporary storage for XmStrings */
        Widget widget12;
        Widget widget13;
        Widget widget14;
@@ -593,18 +581,13 @@ Widget parent;
 
 
 
+void
 create_demo_dialog( parent )
 Widget parent;
 {
-       Display *display = XtDisplay ( parent );
        Widget children[11];      /* Children to manage */
        Arg al[64];           /* Arg List */
        register int ac = 0;      /* Arg Count */
-       char from_s [256];    /* For font list conversion */
-       XrmValue from_value, to_value; /* ditto */
-       int fg, bg;           /* colour values for pixmaps */ 
-       XmString *list_items; /* For list items */
-       int list_item;        /* Index for list_items */
        XmString xmstrings[15];    /* temporary storage for XmStrings */
 
 
index 03640b77b6e431307240a6b634e4fe6b169ceaab..ad1f6da00461b97e356f92b5d245259f8fac3989 100644 (file)
@@ -424,7 +424,7 @@ object 'label1' : XmLabel {
 object 'label2' : XmLabel {
        arguments {
        name = 'label2';
-       XmNlabelString= 'Copyright Â© 1991-1994 by Jamie Zawinski <jwz@mcom.com>';
+       XmNlabelString= 'Copyright Â© 1991-1994 by Jamie Zawinski <jwz@netscape.com>';
        };
 };
 object 'text_area' : XmScrolledList {
index 244eb0ba02b5f0b9d2f5d806f153c6305b01f8fb..e4ef9824cfda5223fd5a6cbae9e18ea0e95c35c3 100644 (file)
@@ -1,4 +1,4 @@
-/*    xscreensaver, Copyright (c) 1993-1995 Jamie Zawinski <jwz@mcom.com>
+/*    xscreensaver, Copyright (c) 1993-1995 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -9,6 +9,16 @@
  * implied warranty.
  */
 
+/* #### If anyone ever finishes the Athena locking code, remove this.
+   But until then, locking requires Motif.
+ */
+#if defined(NO_MOTIF) && !defined(NO_LOCKING)
+# define NO_LOCKING
+#endif
+
+
+#ifndef NO_LOCKING
+
 #if __STDC__
 #include <stdlib.h>
 #include <unistd.h>
 
 #include <X11/Intrinsic.h>
 
+#include "xscreensaver.h"
+
+extern char *screensaver_version;
+extern char *progname;
+extern XtAppContext app;
+extern Bool verbose_p;
+
+#ifdef SCO
+/* SCO has some kind of goofy, nonstandard security crap.  This stuff was
+   donated by one of their victims, I mean users, Didier Poirot <dp@chorus.fr>.
+ */
+# include <sys/security.h>
+# include <sys/audit.h>
+# include <prot.h>
+#endif
+
 #if !__STDC__
 # define _NO_PROTO
 #endif
 
-#include <Xm/Xm.h>
-#include <Xm/List.h>
-#include <Xm/TextF.h>
+#ifdef NO_MOTIF
 
-#include "xscreensaver.h"
+# include <X11/StringDefs.h>
+# include <X11/Xaw/Text.h>
+# include <X11/Xaw/Label.h>
 
-#ifndef NO_LOCKING
+#else /* Motif */
 
-Time passwd_timeout;
+# include <Xm/Xm.h>
+# include <Xm/List.h>
+# include <Xm/TextF.h>
 
-extern char *screensaver_version;
-extern char *progname;
-extern XtAppContext app;
-extern Bool verbose_p;
+#endif /* Motif */
+
+Time passwd_timeout;
 
 extern Widget passwd_dialog;
 extern Widget passwd_form;
@@ -71,14 +98,26 @@ static char user_passwd [255];
 # define GETPW  getpwnam
 #endif
 
+#ifdef SCO
+# define PRPWTYPE struct pr_passwd *
+# define GETPRPW getprpwnam
+#endif
+
 Bool
 lock_init ()
 {
   Bool ok = True;
   char *u;
   PWTYPE p = GETPW ("root");
+
+#ifdef SCO
+  PRPWTYPE prpwd = GETPRPW ("root");
+  if (prpwd && *prpwd->ufld.fd_encrypt)
+    strcpy (root_passwd, prpwd->ufld.fd_encrypt);
+#else /* !SCO */
   if (p && p->PWSLOT && p->PWSLOT[0] != '*')
     strcpy (root_passwd, p->PWSLOT);
+#endif /* !SCO */
   else
     {
       fprintf (stderr, "%s: couldn't get root's password\n", progname);
@@ -87,9 +126,14 @@ lock_init ()
 
   /* It has been reported that getlogin() returns the wrong user id on some
      very old SGI systems... */
-  u = getlogin ();
+  u = (char *) getlogin ();
   if (u)
-    p = GETPW (u);
+    {
+#ifdef SCO
+      prpwd = GETPRPW (u);
+#endif /* SCO */
+      p = GETPW (u);
+    }
   else
     {
       /* getlogin() fails if not attached to a terminal;
@@ -103,11 +147,16 @@ lock_init ()
 #endif
     }
 
+#ifdef SCO
+  if (prpwd && *prpwd->ufld.fd_encrypt)
+    strcpy (user_passwd, prpwd->ufld.fd_encrypt);
+#else /* !SCO */
   if (p && p->PWSLOT &&
       /* p->PWSLOT[0] != '*' */                /* sensible */
       (strlen (p->PWSLOT) > 4)         /* solaris */
       )
     strcpy (user_passwd, p->PWSLOT);
+#endif /* !SCO */
   else
     {
       fprintf (stderr, "%s: couldn't get password of \"%s\"\n", progname, u);
@@ -119,9 +168,11 @@ lock_init ()
 
 
 \f
-#if (XmVersion >= 1002)         /* The `destroy' bug apears to be fixed as   */
-# define DESTROY_WORKS  /* of Motif 1.2.1, but the `verify-callback' */
-#endif                  /* bug is still present. */
+#if defined(NO_MOTIF) || (XmVersion >= 1002)
+   /* The `destroy' bug apears to be fixed as of Motif 1.2.1, but
+      the `verify-callback' bug is still present. */
+# define DESTROY_WORKS
+#endif
 
 static void
 passwd_cancel_cb (button, client_data, call_data)
@@ -147,7 +198,7 @@ passwd_done_cb (button, client_data, call_data)
     passwd_state = pw_fail;
 }
 
-#ifdef VERIFY_CALLBACK_WORKS
+#if !defined(NO_MOTIF) && defined(VERIFY_CALLBACK_WORKS)
 
   /* ####  It looks to me like adding any modifyVerify callback causes
      ####  Motif 1.1.4 to free the the TextF_Value() twice.  I can't see
@@ -214,6 +265,27 @@ Ctrl<Key>M:                done()\n\
 static char translations[] = "<Key>:keypress()";
 #endif
 
+static void
+text_field_set_string (widget, text, position)
+     Widget widget;
+     char *text;
+     int position;
+{
+#ifdef NO_MOTIF
+  XawTextBlock block;
+  block.firstPos = 0;
+  block.length = strlen (text);
+  block.ptr = text;
+  block.format = 0;
+  XawTextReplace (widget, 0, -1, &block);
+  XawTextSetInsertionPoint (widget, position);
+#else  /* !NO_MOTIF */
+  XmTextFieldSetString (widget, text);
+  XmTextFieldSetInsertionPosition (widget, position);
+#endif /* !NO_MOTIF */
+}
+
+
 static void
 keypress (w, event, argv, argc)
      Widget w;
@@ -239,8 +311,8 @@ keypress (w, event, argv, argc)
   s [++i] = 0;
   while (i--)
     s [i] = '*';
-  XmTextFieldSetString (passwd_text, s);
-  XmTextFieldSetInsertionPosition (passwd_text, j + 1);
+
+  text_field_set_string (passwd_text, s, j + 1);
 }
 
 static void
@@ -259,8 +331,8 @@ backspace (w, event, argv, argc)
   s [i] = 0;
   while (i--)
     s [i] = '*';
-  XmTextFieldSetString (passwd_text, s);
-  XmTextFieldSetInsertionPosition (passwd_text, j + 1);
+
+  text_field_set_string (passwd_text, s, j + 1);
 }
 
 static void
@@ -271,7 +343,7 @@ kill_line (w, event, argv, argc)
      Cardinal *argc;
 {
   memset (typed_passwd, 0, sizeof (typed_passwd));
-  XmTextFieldSetString (passwd_text, "");
+  text_field_set_string (passwd_text, "", 0);
 }
 
 static void
@@ -284,7 +356,7 @@ done (w, event, argv, argc)
   passwd_done_cb (w, 0, 0);
 }
 
-#endif /* !VERIFY_CALLBACK_WORKS */
+#endif /* !VERIFY_CALLBACK_WORKS || NO_MOTIF */
 
 static void
 format_into_label (widget, string)
@@ -293,22 +365,38 @@ format_into_label (widget, string)
 {
   char *label;
   char buf [255];
-  XmString xm_label = 0;
-  XmString new_xm_label;
   Arg av[10];
   int ac = 0;
+
+#ifdef NO_MOTIF
+  XtSetArg (av [ac], XtNlabel, &label); ac++;
+  XtGetValues (widget, av, ac);
+#else  /* Motif */
+  XmString xm_label = 0;
+  XmString new_xm_label;
   XtSetArg (av [ac], XmNlabelString, &xm_label); ac++;
   XtGetValues (widget, av, ac);
   XmStringGetLtoR (xm_label, XmSTRING_DEFAULT_CHARSET, &label);
-  if (!strcmp (label, XtName (widget)))
+#endif /* Motif */
+
+  if (!label || !strcmp (label, XtName (widget)))
     strcpy (buf, "ERROR: RESOURCES ARE NOT INSTALLED CORRECTLY");
   else
     sprintf (buf, label, string);
-  new_xm_label = XmStringCreate (buf, XmSTRING_DEFAULT_CHARSET);
+
   ac = 0;
+
+#ifdef NO_MOTIF
+  XtSetArg (av [ac], XtNlabel, buf); ac++;
+#else  /* Motif */
+  new_xm_label = XmStringCreate (buf, XmSTRING_DEFAULT_CHARSET);
   XtSetArg (av [ac], XmNlabelString, new_xm_label); ac++;
+#endif /* Motif */
+
   XtSetValues (widget, av, ac);
+#ifndef NO_MOTIF
   XmStringFree (new_xm_label);
+#endif
   XtFree (label);
 }
 
@@ -339,8 +427,8 @@ roger (button, client_data, call_data)
   if (size > 40) size -= 30;
   x = (xgwa.width - size) / 2;
   y = (xgwa.height - size) / 2;
-  XtSetArg (av [ac], XmNforeground, &fg); ac++;
-  XtSetArg (av [ac], XmNbackground, &bg); ac++;
+  XtSetArg (av [ac], XtNforeground, &fg); ac++;
+  XtSetArg (av [ac], XtNbackground, &bg); ac++;
   XtGetValues (button, av, ac);
   /* if it's black on white, swap it cause it looks better (hack hack) */
   if (fg == BlackPixelOfScreen (screen) && bg == WhitePixelOfScreen (screen))
@@ -355,6 +443,17 @@ roger (button, client_data, call_data)
   XFreeGC (dpy, erase_gc);
 }
 
+#ifdef NO_MOTIF
+
+static void
+make_passwd_dialog (parent)
+     Widget parent;
+{
+  abort (); /* #### */
+}
+
+#else  /* Motif */
+
 static void
 make_passwd_dialog (parent)
      Widget parent;
@@ -374,7 +473,7 @@ make_passwd_dialog (parent)
   XtOverrideTranslations (passwd_text, XtParseTranslationTable (translations));
 #endif
 
-#if (XmVersion >= 1002)
+#if !defined(NO_MOTIF) && (XmVersion >= 1002)
   /* The focus stuff changed around; this didn't exist in 1.1.5. */
   XtVaSetValues (passwd_form, XmNinitialFocus, passwd_text, 0);
 #endif
@@ -387,6 +486,7 @@ make_passwd_dialog (parent)
   format_into_label (passwd_label1, screensaver_version);
 }
 
+#endif /* Motif */
 
 extern void idle_timer ();
 
@@ -412,13 +512,13 @@ passwd_idle_timer (junk1, junk2)
       int ac = 0;
       XGCValues gcv;
       unsigned long fg, bg;
-      XtSetArg (av [ac], XmNheight, &d); ac++;
+      XtSetArg (av [ac], XtNheight, &d); ac++;
       XtGetValues (passwd_done, av, ac);
       ac = 0;
-      XtSetArg (av [ac], XmNwidth, &x); ac++;
-      XtSetArg (av [ac], XmNheight, &y); ac++;
-      XtSetArg (av [ac], XmNforeground, &fg); ac++;
-      XtSetArg (av [ac], XmNbackground, &bg); ac++;
+      XtSetArg (av [ac], XtNwidth, &x); ac++;
+      XtSetArg (av [ac], XtNheight, &y); ac++;
+      XtSetArg (av [ac], XtNforeground, &fg); ac++;
+      XtSetArg (av [ac], XtNbackground, &bg); ac++;
       XtGetValues (passwd_form, av, ac);
       x -= d;
       y -= d;
@@ -455,7 +555,7 @@ pop_passwd_dialog (parent)
   int revert_to;
   typed_passwd [0] = 0;
   passwd_state = pw_read;
-  XmTextFieldSetString (passwd_text, "");
+  text_field_set_string (passwd_text, "", 0);
 
   XGetInputFocus (dpy, &focus, &revert_to);
 #ifndef DESTROY_WORKS
@@ -471,7 +571,7 @@ pop_passwd_dialog (parent)
   pop_up_dialog_box (passwd_dialog, passwd_form, 2);
   XtManageChild (passwd_form);
 
-#if (XmVersion < 1002)
+#if !defined(NO_MOTIF) && (XmVersion < 1002)
   /* The focus stuff changed around; this causes problems in 1.2.1
      but is necessary in 1.1.5. */
   XmProcessTraversal (passwd_text, XmTRAVERSE_CURRENT);
@@ -512,11 +612,12 @@ pop_passwd_dialog (parent)
        case pw_cancel: lose = 0; break;
        default: abort ();
        }
+#ifndef NO_MOTIF
       XmProcessTraversal (passwd_cancel, 0); /* turn off I-beam */
+#endif
       if (lose)
        {
-         XmTextFieldSetString (passwd_text, lose);
-         XmTextFieldSetInsertionPosition (passwd_text, strlen (lose) + 1);
+         text_field_set_string (passwd_text, lose, strlen (lose) + 1);
          passwd_idle_timer_tick = 1;
          id = XtAppAddTimeOut (app, 3000, passwd_idle_timer, 0);
          while (1)
@@ -531,7 +632,7 @@ pop_passwd_dialog (parent)
        }
     }
   memset (typed_passwd, 0, sizeof (typed_passwd));
-  XmTextFieldSetString (passwd_text, "");
+  text_field_set_string (passwd_text, "", 0);
   XtSetKeyboardFocus (parent, None);
 
 #ifdef DESTROY_WORKS
index 2d18248779dcf7dd87c7e460e9b2606503bbff9f..7d5fc1366c0f7e4fc54f59ddf9d430d4f2389d74 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1991-1995 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1991-1995 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -159,7 +159,10 @@ stderr_popup_timer_fn (closure, id)
 
 
 static void
-stderr_callback (XtPointer closure, int *fd, XtIntervalId *id)
+stderr_callback (closure, fd, id)
+     XtPointer closure;
+     int *fd;
+     XtIntervalId *id;
 {
   char *s;
   int left;
index ab969b1326fee782e4741fe02a3cef4ce17863a0..689bbb01654a78b09d326c86f1ebd4d6e6e50571 100644 (file)
@@ -1,4 +1,5 @@
-/* xscreensaver, Copyright (c) 1991-1993 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1991, 1992, 1993, 1995
+ *  Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -80,14 +81,7 @@ extern int putenv (/* const char * */);      /* getenv() is in stdlib.h... */
 extern int kill (pid_t, int);          /* signal() is in sys/signal.h... */
 #endif
 
-# ifndef random
-#  if defined(SVR4) || defined(SYSV)
-#   define random() rand()
-#  else /* !totally-losing-SYSV */
-    extern long random();              /* rand() is in stdlib.h... */
-#  endif /* !totally-losing-SYSV */
-# endif /* random defined */
-
+#include "yarandom.h"
 #include "xscreensaver.h"
 
 /* this must be `sh', not whatever $SHELL happens to be. */
index ff367e4c5ae2f9c796a1e447e3d38bab6087d10c..bb950d8133ab2e5c7fe1367c2ca44d90ec1a0a0a 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1991-1995 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1991-1995 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -141,6 +141,7 @@ BadWindow_ehandler (dpy, error)
      may have been destroyed <30 seconds after it was created.
    */
   if (error->error_code == BadWindow ||
+      error->error_code == BadMatch ||
       error->error_code == BadDrawable)
     return 0;
   XmuPrintDefaultErrorMessage (dpy, error, stderr);
index a9731b02e0b27a474156e02baf73ecb0791933b0..084bce737cf1f84535fc7f712d93123620296972 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1991-1995 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1991-1995 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -724,6 +724,12 @@ raise_window (inhibit_fade, between_hacks_p)
     XInstallColormap (dpy, cmap);
 }
 
+#ifdef __hpux
+ /* Calls to XHPDisableReset and XHPEnableReset must be balanced,
+    or BadAccess errors occur. */
+static Bool hp_locked_p = False;
+#endif /* __hpux */
+
 void
 blank_screen ()
 {
@@ -732,8 +738,9 @@ blank_screen ()
   raise_window (False, False);
   grab_keyboard_and_mouse ();
 #ifdef __hpux
-  if (lock_p)
+  if (lock_p && !hp_locked_p)
     XHPDisableReset (dpy);     /* turn off C-Sh-Reset */
+  hp_locked_p = True;
 #endif
 }
 
@@ -769,7 +776,8 @@ unblank_screen ()
   ungrab_keyboard_and_mouse ();
   restore_real_vroot ();
 #ifdef __hpux
-  if (lock_p)
+  if (lock_p && hp_locked_p)
     XHPEnableReset (dpy);      /* turn C-Sh-Reset back on */
+  hp_locked_p = False;
 #endif
 }
index 15e86063d33b3cbc7b75423d3cf3784ed5dace62..d0aced9414a101801994422f6eee57c3b35f7bd3 100644 (file)
@@ -1,4 +1,5 @@
-/* xscreensaver-command, Copyright (c) 1991-1995 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver-command, Copyright (c) 1991-1995 
+ * Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -26,7 +27,7 @@ static char *screensaver_version;
 static char *usage = "usage: %s -<switch>\n\
 \n\
   This program provides external control of a running xscreensaver process.\n\
-  Version %s, copyright (c) 1991-1994 Jamie Zawinski <jwz@mcom.com>.\n\
+  Version %s, copyright (c) 1991-1994 Jamie Zawinski <jwz@netscape.com>.\n\
 \n\
   -demo                Enter interactive demo mode.\n\
   -deactivate  Turns off the screensaver if it is on, as user input would.\n\
index b00acee924a16a231eabeb9b66778c1bafcc7f56..06e88cbfce30d9547cc3ccc5a5c312353c209660 100644 (file)
@@ -107,4 +107,4 @@ 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@mcom.com>, 13-aug-92.
+Jamie Zawinski <jwz@netscape.com>, 13-aug-92.
index 451f953d3c15e8721eacf5de66468e1363398121..76f68c2eaf05b7b975be07cec23524adb87d5d15 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1991-1995 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1991-1995 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
 #include <X11/extensions/scrnsaver.h>
 #endif /* HAVE_SAVER_EXTENSION */
 
+#include "yarandom.h"
 #include "xscreensaver.h"
 
-#if defined(SVR4) || defined(SYSV)
-# define srandom(i) srand((unsigned int)(i))
-#else
-# ifndef __linux
-extern void srandom P((int));          /* srand() is in stdlib.h... */
-# endif
-#endif
-
 extern char *get_string_resource P((char *, char *));
 extern Bool get_boolean_resource P((char *, char *));
 extern int get_integer_resource P((char *, char *));
@@ -237,9 +230,6 @@ static Atom XA_EXIT, XA_RESTART, XA_DEMO, XA_LOCK;
 #ifdef NO_MOTIF /* kludge */
 Bool demo_mode_p = 0;
 Bool dbox_up_p = 0;
-#ifndef NO_LOCKING
-Time passwd_timeout = 0;
-#endif
 #endif
 
 \f
@@ -253,6 +243,7 @@ static XrmOptionDescRec options [] = {
   { "-timeout",                   ".timeout",          XrmoptionSepArg, 0 },
   { "-cycle",             ".cycle",            XrmoptionSepArg, 0 },
   { "-idelay",            ".initialDelay",     XrmoptionSepArg, 0 },
+  { "-nice",              ".nice",             XrmoptionSepArg, 0 },
   { "-visual",            ".visualID",         XrmoptionSepArg, 0 },
   { "-lock-timeout",      ".lockTimeout",      XrmoptionSepArg, 0 },
   { "-install",                   ".installColormap",  XrmoptionNoArg, "on" },
@@ -276,7 +267,7 @@ static void
 do_help P((void))
 {
   printf ("\
-xscreensaver %s, copyright (c) 1991-1995 by Jamie Zawinski <jwz@mcom.com>.\n\
+xscreensaver %s, copyright (c) 1991-1995 by Jamie Zawinski <jwz@netscape.com>.\n\
 The standard Xt command-line options are accepted; other options include:\n\
 \n\
     -timeout <minutes>         When the screensaver should activate.\n\
@@ -290,8 +281,8 @@ The standard Xt command-line options are accepted; other options include:\n\
     -silent                    Don't.\n\
     -xidle-extension           Use the R5 XIdle server extension.\n\
     -no-xidle-extension        Don't.\n\
-    -saver-extension           Use the R6 MIT-SCREEN-SAVER server extension.\n\
-    -no-saver-extension        Don't.\n\
+    -ss-extension              Use the R6 MIT-SCREEN-SAVER server extension.\n\
+    -no-ss-extension           Don't.\n\
     -lock                      Require a password before deactivating.\n\
     -no-lock                   Don't.\n\
     -lock-timeout <minutes>    Grace period before locking; default 0.\n\
@@ -312,7 +303,7 @@ more details.\n\n",
 #endif
 #if !defined(HAVE_XIDLE_EXTENSION) && !defined(HAVE_SAVER_EXTENSION)
   printf ("Support for the XIDLE and MIT-SCREEN-SAVER server extensions\
- was not\n\enabled at compile-time.\n");
+ was not\nenabled at compile-time.\n");
 #endif /* !HAVE_XIDLE_EXTENSION && !HAVE_SAVER_EXTENSION */
 
   fflush (stdout);
@@ -479,7 +470,7 @@ get_resources P((void))
 
   /* don't set use_saver_extension unless it is explicitly specified */
   if (get_string_resource ("saverExtension", "Boolean"))
-    use_xidle_extension = get_boolean_resource ("saverExtension", "Boolean");
+    use_saver_extension = get_boolean_resource ("saverExtension", "Boolean");
   else
 #ifdef HAVE_SAVER_EXTENSION    /* pick a default */
     use_saver_extension = True;
@@ -660,6 +651,11 @@ initialize (argc, argv)
   nolock_reason = "not compiled with locking support";
 #else
   locking_disabled_p = False;
+
+#ifdef SCO
+  set_auth_parameters(argc, argv);
+#endif
+
   if (! lock_init ())  /* before hack_uid() for proper permissions */
     {
       locking_disabled_p = True;
@@ -691,7 +687,7 @@ initialize (argc, argv)
 
   if (verbose_p)
     printf ("\
-%s %s, copyright (c) 1991-1995 by Jamie Zawinski <jwz@mcom.com>.\n\
+%s %s, copyright (c) 1991-1995 by Jamie Zawinski <jwz@netscape.com>.\n\
  pid = %d.\n", progname, screensaver_version, getpid ());
   ensure_no_screensaver_running ();
 
@@ -820,7 +816,8 @@ main_loop ()
          blank_screen ();
          spawn_screenhack (True);
          if (cycle)
-           cycle_id = XtAppAddTimeOut (app, cycle, (XtPointer)cycle_timer, 0);
+           cycle_id = XtAppAddTimeOut (app, cycle,
+                                       (XtTimerCallbackProc)cycle_timer, 0);
 
 #ifndef NO_LOCKING
          if (lock_p && lock_timeout == 0)
@@ -828,7 +825,8 @@ main_loop ()
          if (lock_p && !locked_p)
            /* locked_p might be true already because of ClientMessage */
            lock_id = XtAppAddTimeOut (app,lock_timeout,
-                                      (XtPointer)activate_lock_timer,0);
+                                      (XtTimerCallbackProc)
+                                      activate_lock_timer,0);
 #endif
 
        PASSWD_INVALID:
@@ -902,7 +900,7 @@ handle_clientmessage (event, until_idle_p)
      XEvent *event;
      Bool until_idle_p;
 {
-  Atom type;
+  Atom type = 0;
   if (event->xclient.message_type != XA_SCREENSAVER)
     {
       char *str;
@@ -911,11 +909,13 @@ handle_clientmessage (event, until_idle_p)
               progname, (verbose_p ? "## " : ""),
               (str ? str : "(null)"));
       if (str) XFree (str);
+      return False;
     }
   if (event->xclient.format != 32)
     {
       fprintf (stderr, "%s: %sClientMessage of format %d received, not 32\n",
               progname, (verbose_p ? "## " : ""), event->xclient.format);
+      return False;
     }
   type = event->xclient.data.l[0];
   if (type == XA_ACTIVATE)
@@ -924,7 +924,15 @@ handle_clientmessage (event, until_idle_p)
        {
          if (verbose_p)
            printf ("%s: ACTIVATE ClientMessage received.\n", progname);
-         return True;
+         if (use_saver_extension)
+           {
+             XForceScreenSaver (dpy, ScreenSaverActive);
+             return False;
+           }
+         else
+           {
+             return True;
+           }
        }
       fprintf (stderr,
               "%s: %sClientMessage ACTIVATE received while already active.\n",
@@ -936,7 +944,15 @@ handle_clientmessage (event, until_idle_p)
        {
          if (verbose_p)
            printf ("%s: DEACTIVATE ClientMessage received.\n", progname);
-         return True;
+         if (use_saver_extension)
+           {
+             XForceScreenSaver (dpy, ScreenSaverReset);
+             return False;
+           }
+         else
+           {
+             return True;
+           }
        }
       fprintf (stderr,
               "%s: %sClientMessage DEACTIVATE received while inactive.\n",
@@ -1062,21 +1078,31 @@ handle_clientmessage (event, until_idle_p)
            }
 
          if (until_idle_p)
-           return True;
+           {
+             if (use_saver_extension)
+               {
+                 XForceScreenSaver (dpy, ScreenSaverActive);
+                 return False;
+               }
+             else
+               {
+                 return True;
+               }
+           }
        }
 #endif
     }
   else
     {
       char *str;
-      str = XGetAtomName (dpy, type);
+      str = (type ? XGetAtomName(dpy, type) : 0);
       if (str)
        fprintf (stderr,
                 "%s: %sunrecognised screensaver ClientMessage %s received\n",
                 progname, (verbose_p ? "## " : ""), str);
       else
        fprintf (stderr,
-                "%s: %sunrecognised screensaver ClientMessage 0x%x received\n",
+               "%s: %sunrecognised screensaver ClientMessage 0x%x received\n",
                 progname, (verbose_p ? "## " : ""),
                 (unsigned int) event->xclient.data.l[0]);
       if (str) XFree (str);
index 751ae0ce868f9df2db03fd356efc19dbd87abe7f..ea792e2dfa39fb5703bb9c4cba0a7ca787d9811e 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1993, 1995 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1993, 1995 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
 
 #ifdef NO_MOTIF
 # define NO_DEMO_MODE
+
+  /* #### If anyone ever finishes the Athena locking code, remove this.
+     Until then, Locking requires Motif. */
 # ifndef NO_LOCKING
 #  define NO_LOCKING
 # endif
+
 #endif
 
 extern char *progname, *progclass;
index 6d7c2f02388723a0243946a3aed6211769385a5f..18bf571a02e8fe0b230ee60efe51d94ff55ece8f 100644 (file)
@@ -216,9 +216,10 @@ The background color used for the stdout/stderr text, if \fBcaptureStdout\fP
 or \fBcaptureStderr\fP are true.  Default: Black.
 .TP 8
 .B programs \fR(class \fBPrograms\fP)
-The graphics hacks which \fIxscreensaver\fP runs when the user is idle.
-The value of this resource is a string, one \fIsh\fP command per line.
-Each line must contain exactly one command -- no semicolons.
+The graphics hacks which \fIxscreensaver\fP runs when the user is idle,
+in addition to those specified in colorPrograms or monoPrograms (as 
+appropriate.)  The value of this resource is a string, one \fIsh\fP command 
+per line.  Each line must contain exactly one command -- no semicolons.
 
 When the screensaver starts up, one of these is selected at random, and
 run.  After the \fIcycle\fP period expires, it is killed, and another
@@ -329,6 +330,13 @@ 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.
 .PP
+(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
+to make that file the value of the \fIDisplayManager*setup\fP resource
+in the \fIxdm-config\fP file.  See the man page for
+.BR xdm (1)
+for more details.)
+.PP
 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.
@@ -534,7 +542,7 @@ 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@mcom.com>, 13-aug-92.
+Jamie Zawinski <jwz@netscape.com>, 13-aug-92.
 Please let me know if you find any bugs or make any improvements.
 
 Thanks to David Wojtowicz for implementing \fIlockTimeout\fP.
index 1c68fa99fe9fff8819645fc81bcb3b79f12e07ad..d2276c49b6125866df8d42d436a1f33851c091ff 100644 (file)
           UTILS = ../utils
        INCLUDES = -I$(UTILS)
         DEFINES = R5ISMS XPMDEFS
-EXTRA_LOAD_FLAGS= $(XMULIB) $(XTOOLLIB) XPMLIB $(EXTENSIONLIB) $(XLIB) -lm
+LOCAL_LIBRARIES = $(XMULIB) $(XTOOLLIB) XPMLIB $(EXTENSIONLIB) $(XLIB) -lm
           HACKS = attraction.c greynetic.c helix.c hopalong.c xroger-hack.c \
                   noseguy.c pyro.c qix.c rocks.c rorschach.c blitspin.c \
                   imsmap.c slidescreen.c decayscreen.c maze.c hypercube.c \
-                  halo.c flame.c pedal.c
+                  halo.c flame.c pedal.c lmorph.c
             MEN = attraction.man greynetic.man helix.man hopalong.man \
                   noseguy.man pyro.man xroger.man qix.man rocks.man \
                   rorschach.man blitspin.man imsmap.man slidescreen.man \
                   decayscreen.man maze.man hypercube.man halo.man flame.man \
-                  pedal.man
+                  pedal.man lmorph.man
        TARFILES = README Imakefile screenhack.c $(HACKS) screenhack.h \
                   vroot.h xlock.h default.xbm $(MEN) .gdbinit noses/\*
 
@@ -42,14 +42,16 @@ echo_tarfiles:
 all:: p                                                                         @@\
 p: deps screenhack.h ps.o $(DEPLIBS)                                    @@\
        RemoveTargetProgram($@)                                          @@\
-       $(CC) -o $@ $(LDOPTIONS) deps ps.o $(LDLIBS) $(EXTRA_LOAD_FLAGS) @@\
+       $(CCENVSETUP)                                                      \
+       $(CC) -o $@ $(LDOPTIONS) deps ps.o $(LOCAL_LIBRARIES) $(LDLIBS)  @@\
                                                                         @@\
 InstallProgram(p,$(BINDIR))                                             @@\
 InstallManPage(p,$(MANDIR))                                             @@\
 clean::                                                                         @@\
        $(RM) p
 
-HOBJS=screenhack.o $(UTILS)/resources.o $(UTILS)/usleep.o $(UTILS)/visual.o
+HOBJS=screenhack.o $(UTILS)/resources.o $(UTILS)/visual.o \
+                  $(UTILS)/usleep.o $(UTILS)/yarandom.o
 
 ScreenhackTarget (qix, qix, $(HOBJS) $(UTILS)/hsv.o)
 ScreenhackTarget (helix, helix, $(HOBJS) $(UTILS)/hsv.o)
@@ -70,3 +72,4 @@ ScreenhackTarget (hypercube, hypercube, $(HOBJS))
 ScreenhackTarget (halo, halo, $(HOBJS) $(UTILS)/hsv.o)
 ScreenhackTarget (flame, flame, $(HOBJS) $(UTILS)/hsv.o)
 ScreenhackTarget (pedal, pedal, $(HOBJS) $(UTILS)/hsv.o)
+ScreenhackTarget (lmorph, lmorph, $(HOBJS))
index 7844154a8f32c7dbd0c9836e74b546fb4e04a15d..8e3f188f3584f8ac9b9e982c2c8d715a97a67f05 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992, 1995 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -11,7 +11,8 @@
 
 /* Simulation of a pair of quasi-gravitational fields, maybe sorta kinda
    a little like the strong and weak electromagnetic forces.  Derived from
-   a Lispm screensaver by John Pezaris <pz@mit.edu>.
+   a Lispm screensaver by John Pezaris <pz@mit.edu>.  Mouse control and
+   viscosity added by "Philip Edward Cutone, III" <pc2d+@andrew.cmu.edu>.
 
    John sez:
 
    The 1/r^2, -1/r^2, -10/r^2 thresholds proved not only robust but also
    interesting -- the orbs never collided and the threshold viscosity fixed
    the non-conservational problem.
+
+   Philip sez:
+   > An even normal viscosity (rather than the thresholded version to
+   > bleed excess energy) is also not interesting.
+
+   unless you make about 200 points.... set the viscosity to about .8
+   and drag the mouse through it.   it makes a nice wave which travels
+   through the field.
  */
 
-#include "screenhack.h"
-#include "spline.h"
 #include <stdio.h>
 #include <math.h>
-#if __STDC__
-#include <math.h>      /* for M_PI */
-#endif
+#include "screenhack.h"
+#include "spline.h"
 
 struct ball {
   float x, y;
@@ -66,6 +72,11 @@ static int point_stack_size, point_stack_fp, pixel_stack_fp, pixel_stack_size;
 static unsigned long *pixel_stack;
 static unsigned int color_shift;
 
+/*flip mods for mouse interaction*/
+static Bool mouse_p;
+int mouse_x, mouse_y, mouse_mass, root_x, root_y;
+static float viscosity;
+
 static enum object_mode {
   ball_mode, line_mode, polygon_mode, spline_mode, spline_filled_mode,
   tail_mode
@@ -122,6 +133,13 @@ init_balls (dpy, window)
   color_shift = get_integer_resource ("colorShift", "Integer");
   if (color_shift >= 360) color_shift = 5;
 
+  /*flip mods for mouse interaction*/
+  mouse_p = get_boolean_resource ("mouse", "Boolean");
+  mouse_mass = get_integer_resource ("mouseSize", "Integer");
+  mouse_mass =  mouse_mass *  mouse_mass *10;
+
+  viscosity = get_float_resource ("viscosity", "Float");
+
   mode_str = get_string_resource ("mode", "Mode");
   if (! mode_str) mode = ball_mode;
   else if (!strcmp (mode_str, "balls")) mode = ball_mode;
@@ -272,6 +290,7 @@ compute_force (i, dx_ret, dy_ret)
      float *dx_ret, *dy_ret;
 {
   int j;
+  float x_dist, y_dist, dist, dist2;
   *dx_ret = 0;
   *dy_ret = 0;
   for (j = 0; j < npoints; j++)
@@ -298,6 +317,28 @@ compute_force (i, dx_ret, dy_ret)
          *dy_ret += (frand (10.0) - 5.0);
        }
     }
+
+  if (mouse_p)
+    {
+      x_dist = mouse_x - balls [i].x;
+      y_dist = mouse_y - balls [i].y;
+      dist2 = (x_dist * x_dist) + (y_dist * y_dist);
+      dist = sqrt (dist2);
+       
+      if (dist > 0.1) /* the balls are not overlapping */
+       {
+         float new_acc = ((mouse_mass / dist2) *
+                          ((dist < threshold) ? -1.0 : 1.0));
+         float new_acc_dist = new_acc / dist;
+         *dx_ret += new_acc_dist * x_dist;
+         *dy_ret += new_acc_dist * y_dist;
+       }
+      else
+       {               /* the balls are overlapping; move randomly */
+         *dx_ret += (frand (10.0) - 5.0);
+         *dy_ret += (frand (10.0) - 5.0);
+       }
+    }
 }
 
 static void
@@ -310,6 +351,15 @@ run_balls (dpy, window)
   static Colormap cmap;
   int i;
 
+  /*flip mods for mouse interaction*/
+  Window  root1, child1;
+  int mask;
+  if (mouse_p)
+    {
+      XQueryPointer(dpy, window, &root1, &child1,
+                   &root_x, &root_y, &mouse_x, &mouse_y, &mask);
+    }
+
   if (tick++ == 500)
     {
       XWindowAttributes xgwa;
@@ -341,11 +391,20 @@ run_balls (dpy, window)
          balls[i].vx *= 0.9;
          balls[i].dx = 0;
        }
+      else if (viscosity != 1)
+       {
+         balls[i].vx *= viscosity;
+       }
+
       if (balls[i].vy > 10)
        {
          balls[i].vy *= 0.9;
          balls[i].dy = 0;
        }
+      else if (viscosity != 1)
+       {
+         balls[i].vy *= viscosity;
+       }
 
       balls[i].x += balls[i].vx;
       balls[i].y += balls[i].vy;
@@ -435,7 +494,7 @@ run_balls (dpy, window)
        abort ();
       if (!mono_p)
        {
-         XColor color2;
+         XColor color2, desired;
          color2 = balls [0].color;
          switch (cmode)
            {
@@ -451,7 +510,18 @@ run_balls (dpy, window)
              abort ();
            }
              
-         if (!XAllocColor (dpy, cmap, &color2))
+         desired = color2;
+         if (XAllocColor (dpy, cmap, &color2))
+           {
+             /* XAllocColor returns the actual RGB that the hardware let us
+                allocate.  Restore the requested values into the XColor struct
+                so that limited-resolution hardware doesn't cause cycle_hue to
+                get "stuck". */
+             color2.red = desired.red;
+             color2.green = desired.green;
+             color2.blue = desired.blue;
+           }
+         else
            {
              color2 = balls [0].color;
              if (!XAllocColor (dpy, cmap, &balls [0].color))
@@ -569,6 +639,9 @@ char *defaults [] = {
   "*threshold: 100",
   "*delay:     10000",
   "*glow:      false",
+  "*mouseSize: 10",
+  "*mouse:     false",
+  "*viscosity: 1",
   "*orbit:     false",
   "*colorShift:        3",
   "*segments:  100",
@@ -588,6 +661,10 @@ XrmOptionDescRec options [] = {
   { "-vx",             ".vx",          XrmoptionSepArg, 0 },
   { "-vy",             ".vy",          XrmoptionSepArg, 0 },
   { "-vmult",          ".vMult",       XrmoptionSepArg, 0 },
+  { "-mouse-size",     ".mouseSize",   XrmoptionSepArg, 0 },
+  { "-mouse",          ".mouse",       XrmoptionNoArg, "true" },
+  { "-nomouse",                ".mouse",       XrmoptionNoArg, "false" },
+  { "-viscosity",      ".viscosity",   XrmoptionSepArg, 0 },
   { "-glow",           ".glow",        XrmoptionNoArg, "true" },
   { "-noglow",         ".glow",        XrmoptionNoArg, "false" },
   { "-orbit",          ".orbit",       XrmoptionNoArg, "true" }
index 334898ee6fc2c304d1df555136a5a8509aae53ff..e3f94243a7005430b29fc4a95fab545f2f9d65f5 100644 (file)
@@ -1,9 +1,22 @@
-.TH XScreenSaver 1 "22-mar-93" "X Version 11"
+.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 "14-Dec-95" "X Version 11"
 .SH NAME
 attraction - interactions of opposing forces
 .SH SYNOPSIS
 .B attraction
-[\-display \fIhost:display.screen\fP] [\-foreground \fIcolor\fP] [\-background \fIcolor\fP] [\-window] [\-root] [\-mono] [\-install] [\-visual \fIvisual\fP] [\-points \fIint\fP] [\-threshold \fIint\fP] [\-mode balls | lines | polygons | splines | filled-splines | tails ] [\-color-mode cycle | random] [\-size \fIint\fP] [\-segments \fIint\fP] [\-delay \fIusecs\fP] [\-color-shift \fIdegrees\fP] [\-radius \fIint\fP] [\-vx \fIint\fP] [\-vy \fIint\fP] [\-glow] [\-noglow] [\-orbit]
+[\-display \fIhost:display.screen\fP] [\-foreground \fIcolor\fP] [\-background \fIcolor\fP] [\-window] [\-root] [\-mono] [\-install] [\-visual \fIvisual\fP] [\-points \fIint\fP] [\-threshold \fIint\fP] [\-mode balls | lines | polygons | splines | filled-splines | tails ] [\-color-mode cycle | random] [\-size \fIint\fP] [\-segments \fIint\fP] [\-delay \fIusecs\fP] [\-color-shift \fIdegrees\fP] [\-radius \fIint\fP] [\-vx \fIint\fP] [\-vy \fIint\fP] [\-glow] [\-noglow] [\-orbit] [\-viscosity \fIfloat\fP] [\-mouse] [\-no-mouse] [\-mouse-size]
 .SH DESCRIPTION
 The \fIattraction\fP program has several visually different modes of 
 operation, all of which are based on the interactions of a set of control
@@ -115,6 +128,31 @@ to decay.
 In orbit mode, the initial velocity of the balls is multiplied by this;
 a number less than 1 will make the balls pull closer together, and a larger
 number will make them move apart.  The default is 1, meaning stability.
+.TP 8
+.B \-viscosity float
+This sets the viscosity of the hypothetical fluid through which the control
+points move; the default is 1, meaning no resistance.  Values higher than 1
+aren't interesting; lower values cause less motion.
+
+One interesting thing to try is
+.EX
+attraction -viscosity 0.8 -points 75 \\
+  -mouse -geometry =500x500
+.EE
+Give it a few seconds to settle down into a stable clump, and then move
+the mouse through it to make "waves".
+.TP 8
+.B \-mouse
+This will cause the mouse to be considered a control point; it will not be
+drawn, but it will influence the other points, so you can wave the mouse
+and influence the images being created.
+.TP 8
+.B \-no-mouse
+Turns off \fB\-mouse\fP.
+.TP 8
+.B \-mouse-size integer
+In \fB\-mouse\fP mode, this sets the mass of the mouse (analagously to the
+\fB\-size\fP parameter.)
 .SH ENVIRONMENT
 .PP
 .TP 8
@@ -136,4 +174,6 @@ 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@mcom.com>, 13-aug-92.
+Jamie Zawinski <jwz@netscape.com>, 13-aug-92.
+
+Viscosity and mouse support by Philip Edward Cutone, III.
index 10f49dd628c7b5d2e7d29bbf86634f98fda7fd8a..debdbaea58a5bf0328644d3b30a96dcb432597b2 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
index 4903faa7956d90d4dcddbf587f0d8ee0d43f19ff..4198883d8782459da2d17117ab230610f5a111db 100644 (file)
@@ -71,7 +71,7 @@ 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@mcom.com>, 17-aug-92.
+Jamie Zawinski <jwz@netscape.com>, 17-aug-92.
 
 Based on SmallTalk code which appeared in the August 1981 issue of Byte
 magazine.
index 32f8167ccae35583e27ab2d088a013a383fc645a..ce18a7ee3a56728bd12db7d60af7ed0442a483f6 100644 (file)
@@ -1,4 +1,5 @@
-/* xscreensaver, Copyright (c) 1992, 1993, 1994 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992, 1993, 1994 
+ * Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
index e010b9df226bce0fc95862410627bb28f1c952d1..3f98e3e3036efbf670f287091a1776a9bbb611ef 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1993 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1993, 1995 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -48,8 +48,6 @@
 
 #include "screenhack.h"
 
-/*#include <math.h>*/
-
 #define POINT_BUFFER_SIZE 10
 #define MAXLEV 4
 
@@ -248,6 +246,23 @@ flame (dpy, window)
   if (delay) usleep (delay);
 }
 
+
+#ifdef __hpux
+/* I don't understand why this is necessary, but I'm told that this program
+   does nothing at all on HP-sUX without it.
+ */
+#undef random
+#undef srandom
+#include <math.h>
+int matherr(x)
+   register struct exception *x;
+{
+  if (x->type == PLOSS) return 1;
+  else return 0;
+}
+#endif /* __hpux */
+
+
 \f
 char *progclass = "Flame";
 
index 67254f8e446efcb54c242434936f41c1334770f1..e53268182a1a223e9bce608115510d86f98cc284 100644 (file)
@@ -69,4 +69,4 @@ supporting documentation.
 Scott Graves <spot@cs.cmu.edu>, 06-Jun-91.n
 
 Ability to run standalone or with \fIxscreensaver\fP added by 
-Jamie Zawinski <jwz@mcom.com>, 18-Oct-93.
+Jamie Zawinski <jwz@netscape.com>, 18-Oct-93.
index dd9312acb87186dda255a9fd78deeb343aef6b62..4dd3f172b608578507d2bff2d0dd72f5b67e5f0c 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992, 1995 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -100,7 +100,7 @@ greynetic (dpy, window)
   gcv.stipple = pixmaps [random () % NBITS];
   if (mono_p)
     {
-      if (random () % 1)
+      if (random () & 1)
        gcv.foreground = fg, gcv.background = bg;
       else
        gcv.foreground = bg, gcv.background = fg;
index 2d187824c21b30b11b6d834ffe8876c03861390a..8638112366466d9b1ab6ad21e623dff00af2eee6 100644 (file)
@@ -49,4 +49,4 @@ 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@mcom.com>, 13-aug-92.
+Jamie Zawinski <jwz@netscape.com>, 13-aug-92.
index b8270ee8960bdbe0b1895e554b6d3501edac2ac8..d61e2ac33c60aeb310024e39281c5ea6e3758a56 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1993 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1993, 1995 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -19,6 +19,7 @@
  */
 
 #include "screenhack.h"
+#include <stdio.h>
 
 struct circle {
   int x, y, radius;
@@ -26,6 +27,11 @@ struct circle {
   int dx, dy;
 };
 
+static enum color_mode {
+  seuss_mode, ramp_mode, random_mode
+} cmode;
+
+
 static struct circle *circles;
 static int count, global_count;
 static Pixmap pixmap, buffer;
@@ -33,7 +39,6 @@ static int width, height, global_inc;
 static int delay;
 static unsigned long fg_pixel, bg_pixel;
 static XColor fgc, bgc;
-static Bool xor_p;
 static GC draw_gc, erase_gc, copy_gc, merge_gc;
 static Bool anim_p;
 static Colormap cmap;
@@ -77,16 +82,34 @@ init_circles (dpy, window)
 {
   XGCValues gcv;
   XWindowAttributes xgwa;
+  char *mode_str = 0;
   XGetWindowAttributes (dpy, window, &xgwa);
   cmap = xgwa.colormap;
   global_count = get_integer_resource ("count", "Integer");
   if (global_count < 0) global_count = 0;
   global_inc = get_integer_resource ("increment", "Integer");
   if (global_inc < 0) global_inc = 0;
-  xor_p = get_boolean_resource ("xor", "Boolean");
-/*  if (mono_p) */ xor_p = True;
   anim_p = get_boolean_resource ("animate", "Boolean");
   delay = get_integer_resource ("delay", "Integer");
+  mode_str = get_string_resource ("colorMode", "ColorMode");
+  if (! mode_str) cmode = random_mode;
+  else if (!strcmp (mode_str, "seuss"))  cmode = seuss_mode;
+  else if (!strcmp (mode_str, "ramp"))   cmode = ramp_mode;
+  else if (!strcmp (mode_str, "random")) cmode = random_mode;
+  else {
+    fprintf (stderr,
+            "%s: colorMode must be seuss, ramp, or random, not \"%s\"\n",
+            progname, mode_str);
+    exit (1);
+  }
+
+  if (mono_p) cmode = seuss_mode;
+  if (cmode == random_mode)
+    cmode = ((random()&3) == 1) ? ramp_mode : seuss_mode;
+
+  if (cmode == ramp_mode)
+    anim_p = False;    /* This combo doesn't work right... */
+
   if (mono_p)
     {
       fg_pixel = get_pixel_resource ("foreground","Foreground", dpy, cmap);
@@ -94,8 +117,15 @@ init_circles (dpy, window)
     }
   else
     {
-      hsv_to_rgb (0,   0.5, 1.0, &fgc.red, &fgc.green, &fgc.blue);
-      hsv_to_rgb (180, 1.0, 0.7, &bgc.red, &bgc.green, &bgc.blue);
+      int r  = random() % 360;
+      int r2 = (random() % 180) + 45;
+      double fs, bs;
+      if (cmode == seuss_mode)
+       fs = 0.5, bs = 1.0;
+      else
+       fs = 1.0, bs = 0.1;
+      hsv_to_rgb (r,          fs, 1.0, &fgc.red, &fgc.green, &fgc.blue);
+      hsv_to_rgb ((r+r2)%360, bs, 0.7, &bgc.red, &bgc.green, &bgc.blue);
       XAllocColor (dpy, cmap, &fgc);
       XAllocColor (dpy, cmap, &bgc);
       fg_pixel = fgc.pixel;
@@ -110,7 +140,7 @@ init_circles (dpy, window)
 #endif
 
   pixmap = XCreatePixmap (dpy, window, width, height, 1);
-  if (xor_p)
+  if (cmode == seuss_mode)
     buffer = XCreatePixmap (dpy, window, width, height, 1);
   else
     buffer = 0;
@@ -124,7 +154,7 @@ init_circles (dpy, window)
   gcv.background = bg_pixel;
   copy_gc = XCreateGC (dpy, window, GCForeground | GCBackground, &gcv);
 
-  if (xor_p)
+  if (cmode == seuss_mode)
     {
       gcv.foreground = 1;
       gcv.background = 0;
@@ -183,10 +213,10 @@ run_circles (dpy, window)
            done = True;
        }
       if (radius > 0 &&
-         (xor_p || circles [0].increment < 0))
+         (cmode == seuss_mode || circles [0].increment < 0))
        XFillArc (dpy,
-                 (xor_p ? pixmap : window),
-                 (xor_p ? draw_gc : merge_gc),
+                 (cmode == seuss_mode ? pixmap : window),
+                 (cmode == seuss_mode ? draw_gc : merge_gc),
                  circles [i].x - radius, circles [i].y - radius,
                  radius * 2, radius * 2, 0, 360*64);
       circles [i].radius += inc;
@@ -223,12 +253,17 @@ run_circles (dpy, window)
          init_circles_1 (dpy, window);
          if (! mono_p)
            {
+             XColor d1, d2;
              cycle_hue (&fgc, 10);
              cycle_hue (&bgc, 10);
              XFreeColors (dpy, cmap, &fgc.pixel, 1, 0);
              XFreeColors (dpy, cmap, &bgc.pixel, 1, 0);
+             d1 = fgc;
+             d2 = bgc;
              XAllocColor (dpy, cmap, &fgc);
              XAllocColor (dpy, cmap, &bgc);
+             fgc.red = d1.red; fgc.green = d1.green; fgc.blue = d1.blue;
+             bgc.red = d2.red; bgc.green = d2.green; bgc.blue = d2.blue;
              XSetForeground (dpy, copy_gc, fgc.pixel);
              XSetBackground (dpy, copy_gc, bgc.pixel);
            }
@@ -254,7 +289,7 @@ run_circles (dpy, window)
 
   if (buffer)
     XCopyPlane (dpy, pixmap, buffer, merge_gc, 0, 0, width, height, 0, 0, 1);
-  else if (!xor_p)
+  else if (cmode != seuss_mode)
     {
       static int ncolors = 0;
       static XColor *colors = 0;
@@ -319,18 +354,17 @@ char *progclass = "Halo";
 char *defaults [] = {
   "Halo.background:    black",         /* to placate SGI */
   "Halo.foreground:    white",
-/*  "*xor:     false", */
-  "*count:     0",
-  "*delay:     100000",
+  "*colorMode:         random",
+  "*count:             0",
+  "*delay:             100000",
   0
 };
 
 XrmOptionDescRec options [] = {
   { "-count",          ".count",       XrmoptionSepArg, 0 },
   { "-delay",          ".delay",       XrmoptionSepArg, 0 },
-  { "-animate",                ".animate",     XrmoptionNoArg, "True" } /* ,
-  { "-xor",            ".xor",         XrmoptionNoArg, "True" },
-  { "-no-xor",         ".xor",         XrmoptionNoArg, "False" } */
+  { "-animate",                ".animate",     XrmoptionNoArg, "True" },
+  { "-mode",           ".colorMode",   XrmoptionSepArg, 0 }
 };
 int options_size = (sizeof (options) / sizeof (options[0]));
 
index 270bc2ffdb3ef39bb82060915044497732f4c43f..5239ab57392f5788f30323901d9f107da9f44921 100644 (file)
@@ -3,7 +3,7 @@
 halo - draw circular patterns
 .SH SYNOPSIS
 .B halo
-[\-display \fIhost:display.screen\fP] [\-foreground \fIcolor\fP] [\-background \fIcolor\fP] [\-window] [\-root] [\-mono] [\-install] [\-visual \fIvisual\fP] [\-count \fIint\fP] [\-delay \fIusecs\fP] [\-animate]
+[\-display \fIhost:display.screen\fP] [\-foreground \fIcolor\fP] [\-background \fIcolor\fP] [\-window] [\-root] [\-mono] [\-install] [\-visual \fIvisual\fP] [\-count \fIint\fP] [\-delay \fIusecs\fP] [\-mode seuss | ramp | random ] [\-animate]
 .SH DESCRIPTION
 The \fIhalo\fP program draws cool patterns based on circles.
 .SH OPTIONS
@@ -29,6 +29,13 @@ or the id number (decimal or hex) of a specific visual.
 .B \-count \fIinteger\fP
 How many circles to draw.  Default 0, meaning random.
 .TP 8
+.B \-mode "seuss | ramp | random"
+In \fIseuss\fP mode, alternating striped curves will be drawn.
+
+In \fIramp\fP mode, a color ramp will be drawn.
+
+\fIrandom\fP means pick the mode randomly.
+.TP 8
 .B \-delay \fImicroseconds\fP
 How much of a delay should be introduced between steps of the animation.
 Default 100000, or about 0.1 second.
@@ -58,4 +65,4 @@ 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@mcom.com>, 6-jul-93.
+Jamie Zawinski <jwz@netscape.com>, 6-jul-93.
index a6ce0aa1c20addbacb6c1f03a29a046718e60e59..84c4fd8ca42340e49b3cc9f7e29f60ba7eae01cc 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992, 1995 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -9,10 +9,8 @@
  * implied warranty.
  */
 
+#include <math.h>
 #include "screenhack.h"
-#ifdef __STDC__
-#include <math.h>      /* for M_PI */
-#endif
 
 static double sins [360];
 static double coss [360];
@@ -196,7 +194,7 @@ char *defaults [] = {
   0
 };
 
-XrmOptionDescRec options [] = { 0 };
+XrmOptionDescRec options [] = { { 0, } };
 int options_size = 0;
 
 void
index 9777f1df144b399eb8af7c51ba7d6a8183f67427..76c7cfef382757331d4434bdaf733fc7b4dcc525 100644 (file)
@@ -47,4 +47,4 @@ 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@mcom.com>, 13-aug-92.
+Jamie Zawinski <jwz@netscape.com>, 13-aug-92.
index ef409f8f4e015f1e9b614c4af21199618dd147fc..2a91ecef80ad8597b344cc97a45cbf5da955eb72 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992, 1995 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -52,8 +52,8 @@
  * 23-Mar-88: Coded HOPALONG routines from Scientific American Sept. 86 p. 14.
  */
 
-#include "screenhack.h"
 #include <math.h>
+#include "screenhack.h"
 
 static GC gc;
 static int batchcount = 1000;
index d30746b64fc4b913a02231fd8303152901047b1b..d812c7b3fbddb47324e2db864b65802f70b9ada6 100644 (file)
@@ -66,4 +66,4 @@ supporting documentation.
 Patrick J. Naughton <naughton@eng.sun.com>, 23-mar-88.
 
 Ability to run standalone or with \fIxscreensaver\fP added by 
-Jamie Zawinski <jwz@mcom.com>, 13-aug-92.
+Jamie Zawinski <jwz@netscape.com>, 13-aug-92.
index e2e71a6b833dca3dd90f1ad860529978539fbd28..05574fb35f5fd9f0b1db66cb243e4047e847fe79 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992, 1995 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -12,8 +12,8 @@
  * and Jamie Zawinski.
  */
 
-#include "screenhack.h"
 #include <math.h>
+#include "screenhack.h"
 
 static Display *dpy;
 static Window window;
index 5efd02c0c775a8faf90e0bfeaae762f1f4e38077..daa66899cc8aae69612f10ae562e47fcba9632ea 100644 (file)
@@ -90,4 +90,4 @@ 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@mcom.com>, 6-dec-92.
+Jamie Zawinski <jwz@netscape.com>, 6-dec-92.
index fc4f2ca1e00d3351e0af5a443fc59bfd991b702d..7a619b94e14817f8c5046588fb06a8fe777b64b2 100644 (file)
@@ -49,8 +49,8 @@ initwin (dsp, win)
   enum mode_t this_mode;
   static Bool rv_p;
   static int ncolors = 0;
-  int shift;
-  double dshift;
+  int shift = 0;
+  double dshift = 0;
     
   XGCValues gcv;
 
index 178b4c51242d152b41347607ff24041817a6da1e..1badced3e7625b471e6540d2796312bcdde6255f 100644 (file)
@@ -60,4 +60,4 @@ stored in the RESOURCE_MANAGER property.
 .SH AUTHOR
 Juergen Nickelsen <nickel@cs.tu-berlin.de>, 23-aug-92.
 
-Hacked on by Jamie Zawinski <jwz@mcom.com>, 24-aug-92.
+Hacked on by Jamie Zawinski <jwz@netscape.com>, 24-aug-92.
diff --git a/hacks/lmorph.c b/hacks/lmorph.c
new file mode 100644 (file)
index 0000000..9672f96
--- /dev/null
@@ -0,0 +1,501 @@
+
+/**************************************************************************
+ *
+ *  FILE            lmorph.c
+ *  MODULE OF       xscreensaver
+ *
+ *  DESCRIPTION     Bilinear interpolation for morphing line shapes.
+ *
+ *  WRITTEN BY      Sverre H. Huseby                Glenn T. Lines
+ *                  Maridalsvn. 122, leil 101       Frysjavn. 3, 5. etg.
+ *                  N-0461 Oslo                     N-0883 Oslo
+ *                  Norway                          Norway
+ *
+ *                  Phone:  +47 22 71 99 08         Phone:  +47 22 23 71 99
+ *                  E-mail: sverrehu@ifi.uio.no     E-mail: gtl@si.sintef.no
+ *
+ *                  The original idea, and the bilinear interpolation
+ *                  mathematics used, emerged in the head of the wise
+ *                  Glenn Terje Lines.
+ *
+ *  MODIFICATIONS   march 1995
+ *                    * Converted from an MS-Windows program to X Window.
+ *
+ **************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include "screenhack.h"
+
+/**************************************************************************
+ *                                                                        *
+ *                       P R I V A T E    D A T A                         *
+ *                                                                        *
+ **************************************************************************/
+
+/* Define MARGINS to make some space around the figure */
+#define MARGINS /**/
+
+#define MAXFIGS    20
+#define TWO_PI     (2.0 * M_PI)
+#define RND(x)     (random() % (x))
+static int
+    cFig = 0,                   /* Number of figure arrays. */
+    cPoint,                     /* Number of points in each array. */
+    nWork,                      /* Current work array number. */
+    nFrom,                      /* Current from array number. */
+    nTo;                        /* Current to array number. */
+static long
+    delay;                      /* usecs to wait between updates. */
+static XPoint
+    *aWork[2],                  /* Working arrays. */
+    *a[MAXFIGS],                /* The figure arrays. */
+    *aTmp,                      /* Used as source when interrupting morph */
+    *aPrev,                     /* Previous points displayed. */
+    *aCurr,                     /* The current points displayed. */  
+    *aFrom,                     /* Figure converting from. */
+    *aTo;                       /* Figure converting to. */
+static double
+    gam,
+    maxGamma = 1.0,
+    delta_gam;
+static GC
+    gcDraw, gcClear;
+static Display
+    *dpy;
+static Window
+    window;
+
+
+
+/**************************************************************************
+ *                                                                        *
+ *                        P U B L I C    D A T A                          *
+ *                                                                        *
+ **************************************************************************/
+
+char *progclass = "LMorph";
+
+char *defaults [] = {
+    "LMorph.background: black",
+    "LMorph.foreground: green",
+    "*points: 150",
+    "*steps: 0",
+    "*delay: 50000",
+    0
+};
+
+XrmOptionDescRec options [] = {
+  { "-points", ".points", XrmoptionSepArg, 0 },
+  { "-steps",  ".steps",  XrmoptionSepArg, 0 },
+  { "-delay",  ".delay",  XrmoptionSepArg, 0 },
+};
+int options_size = (sizeof (options) / sizeof (options[0]));
+
+
+
+/**************************************************************************
+ *                                                                        *
+ *                   P R I V A T E    F U N C T I O N S                   *
+ *                                                                        *
+ **************************************************************************/
+
+static void *xmalloc(size)
+       size_t size;
+{
+    void *ret;
+
+    if ((ret = malloc(size)) == NULL) {
+       fprintf(stderr, "lmorph: out of memory\n");
+       exit(1);
+    }
+    return ret;
+}
+
+
+
+static double frnd()
+{
+    /*
+     *  Hm. for some reason the second line (using RAND_MAX) didn't
+     *  work on some machines, so I always use the first.
+     */
+#undef RAND_MAX
+#ifndef RAND_MAX
+    return (double) (random() & 0x7FFF) / 0x7FFF;
+#else
+    return ((double) random()) / RAND_MAX;
+#endif
+}
+
+
+
+static void initPointArrays()
+{
+    XWindowAttributes wa;
+    int q, w,
+        mx, my,                 /* Max screen coordinates. */
+        mp,                     /* Max point number. */
+        s, rx, ry,
+        marginx, marginy;
+    double scalex, scaley;
+
+    XGetWindowAttributes(dpy, window, &wa);
+    mx = wa.width - 1;
+    my = wa.height - 1;
+    mp = cPoint - 1;
+
+    aWork[0] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+    aWork[1] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+    aTmp     = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+
+
+    /*
+     *  Figure 0
+     */
+    a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+    s = cPoint / 4;
+    for (q = 0; q < s; q++) {
+        a[cFig][q].x = ((double) q / s) * mx;
+        a[cFig][q].y = 0;
+        a[cFig][s + q].x = mx;
+        a[cFig][s + q].y = ((double) q / s) * my;
+        a[cFig][2 * s + q].x = mx - ((double) q / s) * mx;
+        a[cFig][2 * s + q].y = my;
+        a[cFig][3 * s + q].x = 0;
+        a[cFig][3 * s + q].y = my - ((double) q / s) * my;
+    }
+    for (q = 4 * s; q < cPoint; q++) 
+        a[cFig][q].x = a[cFig][q].y = 0;
+    a[cFig][mp].x = a[cFig][0].x;
+    a[cFig][mp].y = a[cFig][0].y;
+    ++cFig;
+
+    /*
+     *  Figure 1
+     */
+    a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+    for (q = 0; q < cPoint; q++) {
+        a[cFig][q].x = ((double) q / cPoint) * mx;
+        a[cFig][q].y = (1.0 - sin(((double) q / mp) * TWO_PI)) * my / 2.0;
+    }
+    ++cFig;
+
+    /*
+     *  Figure 2
+     */
+    a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+    rx = mx / 2;
+    ry = my / 2;
+    for (q = 0; q < cPoint; q++) {
+        a[cFig][q].x = mx / 2 + rx * sin(1 * TWO_PI * (double) q / mp);
+        a[cFig][q].y = my / 2 + ry * cos(3 * TWO_PI * (double) q / mp);
+    }
+    a[cFig][mp].x = a[cFig][0].x;
+    a[cFig][mp].y = a[cFig][0].y;
+    ++cFig;
+
+    /*
+     *  Figure 3
+     */
+    a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+    rx = mx / 2;
+    ry = my / 2;
+    for (q = 0; q < cPoint; q++) {
+        a[cFig][q].x = mx / 2 + ry * sin(3 * TWO_PI * (double) q / mp);
+        a[cFig][q].y = my / 2 + ry * cos(1 * TWO_PI * (double) q / mp);
+    }
+    a[cFig][mp].x = a[cFig][0].x;
+    a[cFig][mp].y = a[cFig][0].y;
+    ++cFig;
+
+    /*
+     *  Figure 4
+     */
+    a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+    rx = mx / 2;
+    ry = my / 2;
+    for (q = 0; q < cPoint; q++) {
+        a[cFig][q].x = mx / 2 + ry * (1 - 0.1 * frnd())
+           * sin(TWO_PI * (double) q / mp);
+        a[cFig][q].y = my / 2 + ry * (1 - 0.1 * frnd())
+           * cos(TWO_PI * (double) q / mp);
+    }
+    a[cFig][mp].x = a[cFig][0].x;
+    a[cFig][mp].y = a[cFig][0].y;
+    ++cFig;
+
+    /*
+     *  Figure 5
+     */
+    a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+    rx = mx / 2;
+    ry = my / 2;
+    for (q = 0; q < cPoint; q++) {
+        a[cFig][q].x = mx / 2 + ry * (0.8 - 0.2 * sin(30 * TWO_PI * q / mp))
+           * sin(TWO_PI * (double) q / mp);
+        a[cFig][q].y = my / 2 + ry * (0.8 - 0.2 * sin(30 * TWO_PI * q / mp))
+           * cos(TWO_PI * (double) q / mp);
+    }
+    a[cFig][mp].x = a[cFig][0].x;
+    a[cFig][mp].y = a[cFig][0].y;
+    ++cFig;
+
+    /*
+     *  Figure 6
+     */
+    a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+    rx = mx / 2;
+    ry = my / 2;
+    for (q = 0; q < cPoint; q++) {
+        a[cFig][q].x = mx / 2 + ry * sin(TWO_PI * (double) q / mp);
+        a[cFig][q].y = my / 2 + ry * cos(TWO_PI * (double) q / mp);
+    }
+    a[cFig][mp].x = a[cFig][0].x;
+    a[cFig][mp].y = a[cFig][0].y;
+    ++cFig;
+
+    /*
+     *  Figure 7
+     */
+    a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+    rx = mx / 2;
+    ry = my / 2;
+    for (q = 0; q < cPoint; q++) {
+        a[cFig][q].x = mx / 2 + rx * cos(TWO_PI * (double) q / mp);
+        a[cFig][q].y = my / 2 + ry * sin(TWO_PI * (double) q / mp);
+    }
+    a[cFig][mp].x = a[cFig][0].x;
+    a[cFig][mp].y = a[cFig][0].y;
+    ++cFig;
+
+    /*
+     *  Figure 8
+     */
+    a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+    for (q = 0; q < cPoint; q++) {
+        a[cFig][q].x = ((double) q / mp) * mx;
+        a[cFig][q].y = (1.0 - cos(((double) q / mp) * 3 * TWO_PI)) * my / 2.0;
+    }
+    ++cFig;
+
+    /*
+     *  Figure 9
+     */
+    a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+    rx = mx / 2;
+    ry = my / 2;
+    for (q = 0; q < cPoint; q++) {
+        a[cFig][q].x = mx / 2 + rx * sin(2 * TWO_PI * (double) q / mp);
+        a[cFig][q].y = my / 2 + ry * cos(3 * TWO_PI * (double) q / mp);
+    }
+    a[cFig][mp].x = a[cFig][0].x;
+    a[cFig][mp].y = a[cFig][0].y;
+    ++cFig;
+
+    /*
+     *  Figure 10
+     */
+    a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+    rx = mx / 2;
+    ry = my / 2;
+    for (q = 0; q < cPoint; q++) {
+        a[cFig][q].x = mx / 2 + ry * sin(5 * TWO_PI * (double) q / mp)
+           * ((double) q / mp);
+        a[cFig][q].y = my / 2 + ry * cos(5 * TWO_PI * (double) q / mp)
+           * ((double) q / mp);
+    }
+    ++cFig;
+
+    /*
+     *  Figure 11
+     */
+    a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+    rx = mx / 2;
+    ry = my / 2;
+    for (q = 0; q < cPoint; q++) {
+        a[cFig][q].x = mx / 2 + ry * sin(6 * TWO_PI * (double) q / mp)
+           * ((double) q / mp);
+        a[cFig][q].y = my / 2 - ry * cos(6 * TWO_PI * (double) q / mp)
+           * ((double) q / mp);
+    }
+    ++cFig;
+
+    /*
+     *  Figure 12
+     */
+    a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+    for (q = 0; q < cPoint; q++) {
+        a[cFig][q].x = ((double) q / mp) * mx;
+        a[cFig][q].y = (1.0 - sin(((double) q / mp) * 5 * TWO_PI)) * my / 2.0;
+    }
+    ++cFig;
+
+#ifdef MARGINS
+    /*
+     *  Make some space around the figures.
+     */
+    marginx = (mx + 1) / 10;
+    marginy = (my + 1) / 10;
+    scalex = (double) ((mx + 1) - 2.0 * marginx) / (mx + 1.0);
+    scaley = (double) ((my + 1) - 2.0 * marginy) / (my + 1.0);
+    for (q = 0; q < cFig; q++)
+       for (w = 0; w < cPoint; w++) {
+           a[q][w].x = marginx + a[q][w].x * scalex;
+           a[q][w].y = marginy + a[q][w].y * scaley;
+       }
+#endif
+}
+
+
+
+static void createPoints()
+{
+    int    q;
+    XPoint *pa = aCurr, *pa1 = aFrom, *pa2 = aTo;
+    long   lg, l1g;
+
+
+    lg = 8192L * gam, l1g = 8192L * (1.0 - gam);
+    for (q = 0; q < cPoint; q++) {
+        pa->x = (short) ((l1g * pa1->x + lg * pa2->x) / 8192L);
+        pa->y = (short) ((l1g * pa1->y + lg * pa2->y) / 8192L);
+        ++pa;
+        ++pa1;
+        ++pa2;
+    }
+}
+
+
+static void drawImage()
+{
+    register int q;
+    XPoint *old0, *old1, *new0, *new1;
+
+    /*
+     *  Problem: update the window without too much flickering. I do
+     *  this by handling each linesegment separately. First remove a
+     *  line, then draw the new line. The problem is that this leaves
+     *  small black pixels on the figure. To fix this, I draw the
+     *  entire figure using XDrawLines() afterwards.
+     */
+    if (aPrev) {
+       old0 = aPrev;
+       old1 = aPrev + 1;
+       new0 = aCurr;
+       new1 = aCurr + 1;
+       for (q = cPoint - 1; q; q--) {
+           XDrawLine(dpy, window, gcClear,
+                     old0->x, old0->y, old1->x, old1->y);
+           XDrawLine(dpy, window, gcDraw,
+                     new0->x, new0->y, new1->x, new1->y);
+           ++old0;
+           ++old1;
+           ++new0;
+           ++new1;
+       }
+    }
+    XDrawLines(dpy, window, gcDraw, aCurr, cPoint, CoordModeOrigin);
+    XFlush(dpy);
+}
+
+static void initLMorph()
+{
+    int               steps;
+    XGCValues         gcv;
+    XWindowAttributes wa;
+    Colormap          cmap;
+    
+    cPoint = get_integer_resource("points", "Integer");
+    steps = get_integer_resource("steps", "Integer");
+    delay = get_integer_resource("delay", "Integer");
+
+    if (steps <= 0)
+      steps = (random() % 400) + 100;
+
+    delta_gam = 1.0 / steps;
+    XGetWindowAttributes(dpy, window, &wa);
+    cmap = wa.colormap;
+    gcv.foreground = get_pixel_resource("foreground", "Foreground", dpy, cmap);
+    gcDraw = XCreateGC(dpy, window, GCForeground, &gcv);
+    XSetForeground(dpy, gcDraw, gcv.foreground);
+    gcv.foreground = get_pixel_resource("background", "Background", dpy, cmap);
+    gcClear = XCreateGC(dpy, window, GCForeground, &gcv);
+    XClearWindow(dpy, window);
+
+    srandom(time(NULL));
+    initPointArrays();
+    aCurr = aWork[nWork = 0];
+    aPrev = NULL;
+    gam = 2.0;
+    nTo = RND(cFig);
+}
+
+static void animateLMorph()
+{
+    if (gam > maxGamma) {
+        gam = 0.0;
+        if (maxGamma == 1.0) {
+            nFrom = nTo;
+            aFrom = a[nFrom];
+        } else {
+            memcpy(aTmp, aCurr, cPoint * sizeof(XPoint));
+            aFrom = aTmp;
+            nFrom = -1;
+        }
+        do {
+            nTo = RND(cFig);
+        } while (nTo == nFrom);
+        aTo = a[nTo];
+        if (RND(2)) {
+            /*
+             *  Reverse the array to get more variation.
+             */
+            int    i1, i2;
+            XPoint p;
+            
+            for (i1 = 0, i2 = cPoint - 1; i1 < cPoint / 2; i1++, i2--) {
+                p = aTo[i1];
+                aTo[i1] = aTo[i2];
+                aTo[i2] = p;
+            }
+        }
+        /*
+         *  It may be nice to interrupt the next run.
+         */
+        if (RND(3) > 0)
+            maxGamma = 0.1 + 0.7 * (RND(1001) / 1000.0);
+        else
+            maxGamma = 1.0;
+    }
+
+    createPoints();
+    drawImage();
+    aPrev = aCurr;
+    aCurr = aWork[nWork ^= 1];
+
+    gam += delta_gam;
+}
+
+
+
+/**************************************************************************
+ *                                                                        *
+ *                    P U B L I C    F U N C T I O N S                    *
+ *                                                                        *
+ **************************************************************************/
+
+void screenhack(disp, win)
+       Display *disp;
+       Window win;
+{
+    dpy = disp;
+    window = win;
+    initLMorph();
+    for (;;) {
+       animateLMorph();
+       screenhack_usleep(delay);
+    }
+}
diff --git a/hacks/lmorph.man b/hacks/lmorph.man
new file mode 100644 (file)
index 0000000..a631f24
--- /dev/null
@@ -0,0 +1,54 @@
+.TH LMORPH 1 "xscreensaver hack"
+.SH NAME
+lmorph \- morphing lines
+.SH SYNOPSIS
+.B lmorph
+[\-display \fIhost:display.screen\fP] [\-foreground \fIcolor\fP] [\-background \fIcolor\fP] [\-window] [\-root] [\-mono] [\-install] [\-visual \fIvisual\fP] [\-points \fIint\fP] [\-steps \fIint\fP] [\-delay \fIusecs\fP]
+.SH DESCRIPTION
+The \fIlmorph\fP program morphs between simple linedrawings using bilinear
+interpolation.
+.SH OPTIONS
+.I lmorph
+accepts the following options:
+.TP 8
+.B \-window
+Draw on a newly-created window. This is the default.
+.TP 8
+.B \-root
+Draw on the root window.
+.TP 8
+.B \-mono 
+If on a color display, pretend we're on a monochrome display.
+.TP 8
+.B \-install
+Install a private colormap for the window.
+.TP 8
+.B \-visual \fIvisual\fP
+Specify which visual to use. Legal values are the name of a visual class,
+or the id number (decimal or hex) of a specific visual.
+.TP 8
+.B \-points \fIinteger\fP
+Number of points in each line drawing. Default is 150 points.
+.TP 8
+.B \-steps \fIinteger\fP
+Interpolation steps from one drawing to the next. Default is 0, which
+means a random number between 100 and 500.
+.TP 8
+.B \-delay \fImicroseconds\fP
+How much of a delay should be introduced between steps of the animation.
+Default 50000.
+.SH ENVIRONMENT
+.PP
+.TP 8
+.B DISPLAY
+to get the default host and display number.
+.TP 8
+.B XENVIRONMENT
+to get the name of a resource file that overrides the global resources
+stored in the RESOURCE_MANAGER property.
+.SH SEE ALSO
+.BR X (1),
+.BR xscreensaver (1)
+.SH AUTHOR
+Sverre H. Huseby <sverrehu@ifi.uio.no> and Glenn T. Lines <gtl@si.sintef.no>,
+built on top of the screen saver routines by Jamie Zawinski <jwz@netscape.com>.
index 5a77195cf41fa80aa8b0818ed1a5f87de73b3e74..6d73796eaf61868216bed60669e50daa8cf233a4 100644 (file)
@@ -1,7 +1,9 @@
 /******************************************************************************
  * [ maze ] ...
  *
- * modified:  [ 3-7-93 ]  Jamie Zawinski <jwz@mcom.com>
+ * modified:  [ 8-11-95 ] Ed James <james@mml.mmc.com>
+ *              added fill of dead-end box to solve_maze while loop.
+ * modified:  [ 3-7-93 ]  Jamie Zawinski <jwz@netscape.com>
  *             added the XRoger logo, cleaned up resources, made
  *             grid size a parameter.
  * modified:  [ 3-3-93 ]  Jim Randell <jmr@mddjmr.fc.hp.com>
@@ -285,7 +287,7 @@ static void enter_square ();
 static void
 create_maze()             /* create a maze layout given the intiialized maze */
 {
-  register int i, newdoor;
+  register int i, newdoor = 0;
   
   do {
     move_list[sqnum].x = cur_sq_x;
@@ -564,6 +566,10 @@ solve_maze()                             /* solve it with graphical feedback */
   /* do it */
   while (1) {
     if ( ++path[i].dir >= 4 ) {
+      XFillRectangle(dpy, win, cgc,
+                    border_x + bw + grid_width * (int)(path[i].x),
+                    border_y + bw + grid_height * (int)(path[i].y),
+                    grid_width - (bw+bw), grid_height - (bw+bw));
       i--;
       draw_solid_square( (int)(path[i].x), (int)(path[i].y), 
                        (int)(path[i].dir), cgc);
@@ -613,7 +619,7 @@ enter_square(n)                            /* move into a neighboring square */
 
 
 /*
- *  jmr additions for Jamie Zawinski's <jwz@mcom.com> screensaver stuff,
+ *  jmr additions for Jamie Zawinski's <jwz@netscape.com> screensaver stuff,
  *  note that the code above this has probably been hacked about in some
  *  arbitrary way.
  */
index a39df17860abff5d0df5b9aa7d9b4f866f09c8a4..3a6542c8f3fcbce5a7147ab00f54af5c201a7d13 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
index 7f7bedb7cfdd7ad64047af8d16cffc801d7776d0..fe18d8dfc35b8d1b8dc5320544cf2aeea7371189 100644 (file)
@@ -71,4 +71,4 @@ Copyright 1985, 1990 by Dan Heller <argv@sun.com>.
 Dan Heller <argv@sun.com>, 1985.
 
 Ability to run standalone or with \fIxscreensaver\fP added by 
-Jamie Zawinski <jwz@mcom.com>, 13-aug-92.
+Jamie Zawinski <jwz@netscape.com>, 13-aug-92.
index 7ca1c40a30af9e2379d9dd1d6476a348115ca166..7c60d8fcf9594998fee47459f3cc3d9b32e94424 100644 (file)
@@ -1,8 +1,8 @@
-/nose.0.left/1.1/Mon Dec 19 04:30:41 1994 Thu Aug 25 15:04:28 1994//
-/nose.0.right/1.1/Mon Dec 19 04:30:41 1994 Thu Aug 25 15:04:29 1994//
-/nose.1.left/1.1/Mon Dec 19 04:30:41 1994 Thu Aug 25 15:04:30 1994//
-/nose.1.right/1.1/Mon Dec 19 04:30:41 1994 Thu Aug 25 15:04:31 1994//
-/nose.down/1.1/Mon Dec 19 04:30:41 1994 Thu Aug 25 15:04:32 1994//
-/nose.front/1.1/Mon Dec 19 04:30:41 1994 Thu Aug 25 15:04:33 1994//
-/nose.left.front/1.1/Mon Dec 19 04:30:41 1994 Thu Aug 25 15:04:34 1994//
-/nose.right.front/1.1/Mon Dec 19 04:30:41 1994 Thu Aug 25 15:04:35 1994//
+/nose.0.left/1.1/Fri Mar 17 18:30:19 1995 Thu Aug 25 15:04:28 1994//
+/nose.0.right/1.1/Fri Mar 17 18:30:19 1995 Thu Aug 25 15:04:29 1994//
+/nose.1.left/1.1/Fri Mar 17 18:30:20 1995 Thu Aug 25 15:04:30 1994//
+/nose.1.right/1.1/Fri Mar 17 18:30:20 1995 Thu Aug 25 15:04:31 1994//
+/nose.down/1.1/Fri Mar 17 18:30:20 1995 Thu Aug 25 15:04:32 1994//
+/nose.front/1.1/Fri Mar 17 18:30:20 1995 Thu Aug 25 15:04:33 1994//
+/nose.left.front/1.1/Fri Mar 17 18:30:20 1995 Thu Aug 25 15:04:34 1994//
+/nose.right.front/1.1/Fri Mar 17 18:30:20 1995 Thu Aug 25 15:04:35 1994//
index b39fef4f44baaa0a8406ff6a4576495cb10da495..8cde8d53666bd617bf224b809a5a682016174faa 100644 (file)
@@ -372,11 +372,11 @@ char *progclass = "Pedal";
  * should be dark.
  */
 char *defaults [] = {
+  "Pedal.background:           black",         /* to placate SGI */
+  "Pedal.foreground:           white",
   "*delay:                     5",
   "*fadedelay:                 200000",
   "*maxlines:                  1000",
-  "*foreground:                 white",
-  "*background:                 black",
   0
 };
 
index f7df260bfd11c7d8ed06c5e6e732863ecd82c8f8..996f7833d72dc7723662283aef7ec8c542350aaa 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1992, 1994 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992, 1994 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
index 5e83518a63fae0e70650381bcbe63a86b7696914..8edb9669c93d1b10008a64198d2f4ba789cebd6f 100644 (file)
@@ -57,4 +57,4 @@ 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@mcom.com>, 13-aug-92.
+Jamie Zawinski <jwz@netscape.com>, 13-aug-92.
index e45c795595c0ad6f5b8b49cb45dccd05d4010fdc..c26e736746cfef80bb4a0fc7c50132ee65e60814 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992, 1995 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -400,9 +400,21 @@ add_qline (dpy, window, cmap, qline, prev_qline, qix)
 
   if (!mono_p && !transparent_p)
     {
+      XColor desired;
       cycle_hue (&qline->color, color_shift);
       qline->color.flags = DoRed | DoGreen | DoBlue;
-      if (!XAllocColor (dpy, cmap, &qline->color))
+      desired = qline->color;
+      if (XAllocColor (dpy, cmap, &qline->color))
+       {
+         /* XAllocColor returns the actual RGB that the hardware let us
+            allocate.  Restore the requested values into the XColor struct
+            so that limited-resolution hardware doesn't cause cycle_hue to
+            get "stuck". */
+         qline->color.red = desired.red;
+         qline->color.green = desired.green;
+         qline->color.blue = desired.blue;
+       }
+      else
        {
          qline->color = prev_qline->color;
          if (!XAllocColor (dpy, cmap, &qline->color))
index c67221c0b8cc4493d0518e0a4adf862040cbcc51..816a55a36bf7eaec5daacb6a62221f50bfe37989 100644 (file)
@@ -111,4 +111,4 @@ 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@mcom.com>, 13-aug-92.
+Jamie Zawinski <jwz@netscape.com>, 13-aug-92.
index 8cf49cf35f3bf5d5a5bb8c39f5cec67923aa846d..4e9e901e9f8deef4ab0a33833a042470a6b65de5 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992, 1995 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
    John Nguyen <johnn@hx.lcs.mit.edu>
  */
 
-#include "screenhack.h"
 #include <stdio.h>
 #include <math.h>
-#if __STDC__
-#include <math.h>      /* for M_PI */
-#endif
+#include "screenhack.h"
 
 #define MIN_DEPTH 2            /* rocks disappar when they get this close */
 #define MAX_DEPTH 60           /* this is where rocks appear */
@@ -148,7 +145,7 @@ init_pixmaps (dpy, window)
 {
   int i;
   XGCValues gcv;
-  GC fg_gc = 0, bg_gc;
+  GC fg_gc = 0, bg_gc = 0;
   pixmaps [0] = pixmaps [1] = 0;
   for (i = MIN_DEPTH; i < MAX_WIDTH; i++)
     {
index af45f894a1dbb3ce5dfc0bd5c5b3433ee110f67a..22256d3eb296d7a28919a9440a4ba239838e0855 100644 (file)
@@ -68,4 +68,4 @@ express or implied warranty.
 .SH AUTHOR
 Based on Lisp Machine code copyright 1988 John Nguyen <johnn@hx.lcs.mit.edu>.
 
-Ported to C and X by Jamie Zawinski <jwz@mcom.com>, 13-aug-92.
+Ported to C and X by Jamie Zawinski <jwz@netscape.com>, 13-aug-92.
index bb17ffc9f54ca553b4a81eb0b89c4dfbaf1d5aed..bea709cd995a716aebb0f676af07e6aee4fe97db 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
index 1b0b249555f05752e1cfc81db820511ce3f853bc..4619f0ff2a587679d5669c6dbaaef4af86a1f064 100644 (file)
@@ -61,4 +61,4 @@ 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@mcom.com>, 13-aug-92.
+Jamie Zawinski <jwz@netscape.com>, 13-aug-92.
index 426155363e0497dbc8de5a2efcbdab212a0142a0..6c7a03003044567373a2264ce231c53f6ed08a0f 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1992, 1995 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992, 1995 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
index fb3de4ce92ce3e19e717fd831db839810ee949b3..9be436724f35c94f344a7d37996debbb4e89c05a 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1992-1995 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992-1995 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
 #include <stdlib.h>
 #endif
 
+#ifdef __hpux
+ /* Which of the ten billion standards does values.h belong to?
+    What systems always have it? */
+# include <values.h>
+#endif
+
 #include <X11/Xlib.h>
 #include <X11/Xresource.h>
 #include <X11/Xos.h>
@@ -70,26 +76,11 @@ extern XrmOptionDescRec options [];
 extern int options_size;
 extern char *defaults [];
 
-#if __STDC__
-# if (defined(SVR4) || defined(SYSV)) && !defined(__sgi)
-#  ifndef random
-    extern int rand (void);
-#   define random() rand()
-#  endif
-#  ifndef srandom
-    extern void srand (unsigned int);
-#   define srandom(i) srand((unsigned int)(i))
-#  endif
-# else /* !totally-losing-SYSV */
-#  ifndef random
-    extern long random (void);
-#  endif
-#  ifndef srandom
-    extern int srandom (unsigned int);
-#  endif
-# endif /* !totally-losing-SYSV */
-#endif /* __STDC__ */
+/* Screw it, we'll just use our own RNG.  See xscreensaver/utils/yarandom.c. */
+#include "yarandom.h"
 
+
+#undef P
 #if __STDC__
 # define P(x)x
 #else
@@ -126,11 +117,23 @@ extern Pixmap grab_screen_image P((Display *dpy, Window window, int root_p));
 extern void copy_default_colormap_contents P((Display *dpy, Colormap to_cmap,
                                              Visual *to_visual));
 
+#if defined (__GNUC__) && (__GNUC__ >= 2)
+ /* Implement frand using GCC's statement-expression extension. */
+
+# define frand(f)                                                      \
+  ({ double tmp = (((double) random()) /                               \
+                  (((double) ((unsigned int)~0)) / ((double) (f+f)))); \
+     tmp < 0 ? (-tmp) : tmp; })
+
+#else /* not GCC2 - implement frand using a global variable.*/
+
 static double _frand_tmp_;
-#define frand(f)                                                       \
- (_frand_tmp_ = (((double) random()) /                                         \
-                (((double) ((unsigned int)~0)) / ((double) (f+f)))),   \
-  _frand_tmp_ < 0 ? (-_frand_tmp_) : _frand_tmp_)
+# define frand(f)                                                      \
+  (_frand_tmp_ = (((double) random()) /                                \
+                 (((double) ((unsigned int)~0)) / ((double) (f+f)))),  \
+   _frand_tmp_ < 0 ? (-_frand_tmp_) : _frand_tmp_)
+
+#endif /* not GCC2 */
 
 #undef P
 #endif /* _SCREENHACK_H_ */
index 52f0d975d4a7a35339f91c6e70f447c5a21cd899..6c8ccf71b7318d03035158393400905a0ad452a6 100644 (file)
@@ -1,4 +1,5 @@
-/* xscreensaver, Copyright (c) 1992, 1993, 1994 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992, 1993, 1994 
+ * Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
index 9dc86fc07dfbcf18e7008ef44ec481faaf827f11..3d03dc50a195316b09fa6df0bca66096f755953b 100644 (file)
@@ -65,4 +65,4 @@ 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@mcom.com>, 3-dec-92.
+Jamie Zawinski <jwz@netscape.com>, 3-dec-92.
index a53a99a9444273dd64f9dd5962ea9c78ab1c117a..19e5fdab1fd879d24d8e6b1601ad6657a81ccc37 100644 (file)
@@ -5,6 +5,9 @@
 **  for xlock 2.3 and xscreensaver 1.2, 28AUG92
 **
 **
+**  Modified for xlockmore 3.0 by Anthony Thyssen <anthony@cit.gu.edu.au>
+**  on August 1995.
+**
 **  To use, just copy the appropriate file from xlock, add a target
 **  for it in the Imakefile, and do the following:
 **
@@ -38,8 +41,13 @@ static Colormap cmap;
 
 static int batchcount;
 static unsigned int delay;
+static unsigned int cycles;
 static double saturation;
 
+#ifndef min
+#define min(a,b) ((a)<(b)?(a):(b))
+#endif
+
 typedef struct {
   GC gc;
   int npixels;
@@ -75,7 +83,8 @@ My_XGetWindowAttributes (dpy, win, xgwa)
     bg_pixel = get_pixel_resource ("background", "Background", dpy, cmap);
     if (! mono_p) {
       for (npixels = 0; npixels < i; npixels++) {
-        hsv_to_rgb ((360*npixels)/i, saturation, 1.0, &color.red, &color.green, &color.blue);
+        hsv_to_rgb ((360*npixels)/i, saturation, 1.0,
+                   &color.red, &color.green, &color.blue);
         if (! XAllocColor (dpy, cmap, &color))
           break;
         pixels[npixels] = color.pixel;
@@ -86,6 +95,9 @@ My_XGetWindowAttributes (dpy, win, xgwa)
     n = get_integer_resource ("count", "Integer");
     if (n > 0) batchcount = n;
 
+    n = get_integer_resource ("cycles", "Integer");
+    if (n >= 0) cycles = n;
+
     gcv.foreground = fg_pixel;
     gcv.background = bg_pixel;
     gc = XCreateGC (dpy, win, GCForeground|GCBackground, &gcv);
@@ -113,6 +125,8 @@ char *defaults[] = {
   "*foreground:        white",
   "*ncolors:   64",
   "*delay:     -1",
+  "*count:     -1",
+  "*cycles:    -1",
   0
 };
 
@@ -120,10 +134,11 @@ XrmOptionDescRec options[] = {
   {"-count",   ".count",       XrmoptionSepArg, 0},
   {"-ncolors", ".ncolors",     XrmoptionSepArg, 0},
   {"-delay",   ".delay",       XrmoptionSepArg, 0},
+  {"-cycles",   ".cycles",      XrmoptionSepArg, 0},
 };
 int options_size = (sizeof (options) / sizeof (options[0]));
 
-#define PROGRAM(Y,Z,D,B,S) \
+#define PROGRAM(Y,Z,D,B,C,S) \
 char *progclass = Y;                   \
                                        \
 void screenhack (dpy, window)          \
@@ -132,15 +147,14 @@ void screenhack (dpy, window)             \
 {                                      \
   batchcount = B;                      \
   delay = D;                           \
+  cycles = C;                           \
   saturation = S;                      \
   dsp = dpy;                           \
                                        \
+  init##Z (window);                    \
   while (1) {                          \
-    init##Z (window);                  \
-    for (;;) {                         \
-      draw##Z (window);                        \
-      XSync (dpy, True);               \
-      if (delay) usleep (delay);       \
-    }                                  \
+    draw##Z (window);                  \
+    XSync (dpy, True);                 \
+    if (delay) usleep (delay);         \
   }                                    \
 }
index 72bd2d3c76283cf9f12ee202733818ea637d8a2f..615ade168c7c81e13ceb9490ac119a648db17164 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1991-1994 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1991-1994 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
index 2eeb2e66e1dc3490e4cde567017f8ce3e5aa659d..799f5005d915ab8a9c378e6bd4a6a8c4e66c309a 100644 (file)
@@ -49,4 +49,4 @@ notice appear in supporting documentation.  No representations are made about
 the  suitability of fnord this software for any purpose.  It is provided "as
 is" without express or fnord implied warranty.
 .SH AUTHOR
-Jamie Zawinski <jwz@mcom.com>, 13-aug-92.
+Jamie Zawinski <jwz@netscape.com>, 13-aug-92.
index 25642827a5cc0f99656fa0e5900ffe37b9b6d578..5f61d60a10ebd248fc0505b96c3313360d4b8c83 100644 (file)
     DEFINES = R5ISMS
 #endif
        SRCS = fade.c hsv.c resources.c spline.c usleep.c xroger.c \
-              grabscreen.c visual.c
+              grabscreen.c visual.c yarandom.c
        OBJS = fade.o hsv.o resources.o spline.o usleep.o xroger.o \
-              grabscreen.o visual.o
-   TARFILES = README Imakefile ad2c $(SRCS) spline.h version.h
+              grabscreen.o visual.o yarandom.o
+   TARFILES = README Imakefile ad2c $(SRCS) spline.h yarandom.h version.h
 
 all:: $(OBJS)
 
index 16f815ce066488b3d18dd477a193b29842e3df43..40fe9dddc486cff338fca43fd09fcca790b607d9 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
index 57e695fe5557fe58c86108949d8494d7e781b3ef..692e42e104ae4f013909fa5cf97912fb4910a1d3 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1992, 1993, 1994 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992, 1993, 1994 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
index 2a88dffc3fb6cd64e4c6a0ae300d172496ccbd8f..c5109120af08a8f73f8936d17c83ac06e5bc50c9 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
index 1e73abec15558679ff9ed75017c68df88d5b9879..02c499b3e6a232e510742b5d1a85c7a1c221c2bb 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
index 2de351eb3cde326c43f940d86a2c283c2956406d..30e7f152c914025f35b1e90c8dbd2d96b96eb30e 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
index f7d2887184666117440bb940f56bd58c929832e8..a56e38a5d20b65d90062ee0bd5ee9decd2bd4d07 100644 (file)
@@ -1,2 +1,2 @@
 static char *screensaver_id =
-       "@(#)xscreensaver 1.25, by Jamie Zawinski (jwz@mcom.com)";
+       "@(#)xscreensaver 1.26, by Jamie Zawinski (jwz@netscape.com)";
index 2737752d9d31ca21c1cc6933f8199bc36990aaf0..cc8b5729cfb17751f4e9aae1110184c632dfe1f7 100644 (file)
@@ -1,4 +1,5 @@
-/* xscreensaver, Copyright (c) 1993, 1994, 1995 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1993, 1994, 1995 
+ * Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
index 01fd7d7f9a05bb193496a7540a2f6a661f7c416f..039a97fc58cb3c6d8122a783b219885eab771172 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1991-1993 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1991-1993 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
diff --git a/utils/yarandom.c b/utils/yarandom.c
new file mode 100644 (file)
index 0000000..228b81c
--- /dev/null
@@ -0,0 +1,72 @@
+/* ya_random -- Yet Another Random Number Generator.
+
+   The unportable mess that is rand(), random(), drand48() and friends led me
+   to ask Phil Karlton <karlton@netscape.com> what the Right Thing to Do was.
+   He responded with this.  It is non-cryptographically secure, reasonably
+   random (more so than anything that is in any C library), and very fast.
+
+   I don't understand how it works at all, but he says "look at Knuth,
+   Vol. 2 (original edition), page 26, Algorithm A.  In this case n=55,
+   k=20 and m=2^32."
+
+   So there you have it.
+ */
+
+#include <unistd.h>   /* for getpid() */
+#include <sys/time.h> /* for gettimeofday() */
+
+
+/* The following 'random' numbers are taken from CRC, 18th Edition, page 622.
+   Each array element was taken from the corresponding line in the table,
+   except that a[0] was from line 100. 8s and 9s in the table were simply
+   skipped. The high order digit was taken mod 4.
+ */
+#define VectorSize 55
+static unsigned int a[VectorSize] = {
+ 035340171546, 010401501101, 022364657325, 024130436022, 002167303062, /*  5 */
+ 037570375137, 037210607110, 016272055420, 023011770546, 017143426366, /* 10 */
+ 014753657433, 021657231332, 023553406142, 004236526362, 010365611275, /* 14 */
+ 007117336710, 011051276551, 002362132524, 001011540233, 012162531646, /* 20 */
+ 007056762337, 006631245521, 014164542224, 032633236305, 023342700176, /* 25 */
+ 002433062234, 015257225043, 026762051606, 000742573230, 005366042132, /* 30 */
+ 012126416411, 000520471171, 000725646277, 020116577576, 025765742604, /* 35 */
+ 007633473735, 015674255275, 017555634041, 006503154145, 021576344247, /* 40 */
+ 014577627653, 002707523333, 034146376720, 030060227734, 013765414060, /* 45 */
+ 036072251540, 007255221037, 024364674123, 006200353166, 010126373326, /* 50 */
+ 015664104320, 016401041535, 016215305520, 033115351014, 017411670323  /* 55 */
+};
+
+static int i1, i2;
+
+unsigned int ya_random()
+{
+  register int ret = a[i1] + a[i2];
+  a[i1] = ret;
+  i1 = i1 >= VectorSize ? 0 : i1 + 1;
+  i2 = i2 >= VectorSize ? 0 : i2 + 1;
+  return ret;
+}
+
+void ya_rand_init(seed)
+   register unsigned int seed;
+{
+  int i;
+  if (seed == 0)
+    {
+      struct timeval tp;
+      struct timezone tzp;
+      gettimeofday(&tp, &tzp);
+      /* ignore overflow */
+      seed = (999*tp.tv_sec) + (1001*tp.tv_usec) + (1003 * getpid());
+    }
+
+  a[0] += seed;
+  for (i = 1; i < VectorSize; i++)
+    {
+      seed = a[i-1]*1001 + seed*999;
+      a[i] += seed;
+    }
+
+  i1 = a[0] % VectorSize;
+  i2 = (i1 + 024) % VectorSize;
+}
diff --git a/utils/yarandom.h b/utils/yarandom.h
new file mode 100644 (file)
index 0000000..53b22fd
--- /dev/null
@@ -0,0 +1,19 @@
+#undef random
+#undef rand
+#undef drand48
+#undef srandom
+#undef srand
+#undef srand48
+
+#define random()   ya_random()
+#define srandom(i) ya_rand_init(0)
+
+#undef P
+#if __STDC__
+# define P(x)x
+#else
+# define P(x)()
+#endif
+
+extern unsigned int ya_random P((void));
+extern void ya_rand_init P((unsigned int));