http://packetstormsecurity.org/UNIX/admin/xscreensaver-4.01.tar.gz
[xscreensaver] / hacks / noseguy.c
index aa0f1c6c39765bedbce1d44bcb65842e4f9eaf86..f7c8013dee02e3c7bf07ae26e624c33021269500 100644 (file)
@@ -1,5 +1,5 @@
 /* xscreensaver, Copyright (c) 1992, 1996, 1997, 1998
- *  Jamie Zawinski <jwz@netscape.com>
+ *  Jamie Zawinski <jwz@jwz.org>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
  */
 
 /* Make a little guy with a big nose and a hat wanter around the screen,
-   spewing out messages.  Derived from xnlock by Dan Heller <argv@sun.com>.
+   spewing out messages.  Derived from xnlock by 
+   Dan Heller <argv@danheller.com>.
  */
 
 #include "screenhack.h"
+#include "xpm-pixmap.h"
 #include <stdio.h>
 
 extern FILE *popen (const char *, const char *);
@@ -55,9 +57,7 @@ static int state;     /* indicates states: walking or getting passwd */
 
 static void (*next_fn) (void);
 
-#ifdef HAVE_XPM
-# include <X11/xpm.h>
-
+#if defined(HAVE_GDK_PIXBUF) || defined(HAVE_XPM)
 # include "images/noseguy/nose-f1.xpm"
 # include "images/noseguy/nose-f2.xpm"
 # include "images/noseguy/nose-f3.xpm"
@@ -85,41 +85,19 @@ init_images (void)
     &left_front, &right_front, &front, &down
   };
   int i;
-#ifdef HAVE_XPM
+#if defined(HAVE_GDK_PIXBUF) || defined(HAVE_XPM)
+
   static char **bits[] = {
     nose_l1_xpm, nose_l2_xpm, nose_r1_xpm, nose_r2_xpm,
     nose_f2_xpm, nose_f3_xpm, nose_f1_xpm, nose_f4_xpm
   };
+
+
   for (i = 0; i < sizeof (images) / sizeof(*images); i++)
     {
-      XWindowAttributes xgwa;
-      XpmAttributes xpmattrs;
-      Pixmap pixmap = 0;
-      int result;
-      xpmattrs.valuemask = 0;
-
-      XGetWindowAttributes (dpy, window, &xgwa);
-
-# ifdef XpmCloseness
-      xpmattrs.valuemask |= XpmCloseness;
-      xpmattrs.closeness = 40000;
-# endif
-# ifdef XpmVisual
-      xpmattrs.valuemask |= XpmVisual;
-      xpmattrs.visual = xgwa.visual;
-# endif
-# ifdef XpmDepth
-      xpmattrs.valuemask |= XpmDepth;
-      xpmattrs.depth = xgwa.depth;
-# endif
-# ifdef XpmColormap
-      xpmattrs.valuemask |= XpmColormap;
-      xpmattrs.colormap = xgwa.colormap;
-# endif
-
-      result = XpmCreatePixmapFromData(dpy, window, bits[i],
-                                      &pixmap, 0 /* mask */, &xpmattrs);
-      if (!pixmap || (result != XpmSuccess && result != XpmColorError))
+      Pixmap pixmap = xpm_data_to_pixmap (dpy, window, bits[i],
+                                          0, 0, 0);
+      if (!pixmap)
        {
          fprintf (stderr, "%s: Can't load nose images\n", progname);
          exit (1);
@@ -542,7 +520,9 @@ get_words (void)
              sprintf (buf, "\"%s\" produced no output!", orig_program);
            else if (!first_time &&
                     (strstr (buf, ": not found") ||
-                     strstr (buf, ": Not found")))
+                     strstr (buf, ": Not found") ||
+                      strstr (buf, ": command not found") ||
+                      strstr (buf, ": Command not found")))
              switch (random () % 20)
                {
                case 1: strcat (buf, "( Get with the program, bub. )\n");
@@ -610,14 +590,14 @@ get_words (void)
 char *progclass = "Noseguy";
 
 char *defaults [] = {
-  "Noseguy.background: black",         /* to placate SGI */
-  "Noseguy.foreground: gray80",
+  ".background:                black",
+  ".foreground:                gray80",
 #ifndef VMS
   "*mode:              program",
 #else
   "*mode:              string",
 #endif
-  "*program:           " ZIPPY_PROGRAM,
+  "*program:           " FORTUNE_PROGRAM,
   "noseguy.font:       -*-new century schoolbook-*-r-*-*-*-180-*-*-*-*-*-*",
   0
 };
@@ -713,7 +693,8 @@ screenhack (Display *d, Window w)
   while (1)
     {
       next_fn();
-      XSync (dpy, True);
+      XSync (dpy, False);
+      screenhack_handle_events (dpy);
       usleep (interval * 1000);
     }
 }