-/* xscreensaver, Copyright (c) 1992-1997 Jamie Zawinski <jwz@netscape.com>
+/* xscreensaver, Copyright (c) 1992-1997, 2003 Jamie Zawinski <jwz@jwz.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
*/
#include "screenhack.h"
+#include "xpm-pixmap.h"
#include <stdio.h>
-#ifdef HAVE_XPM
-# include <X11/xpm.h>
-# ifndef PIXEL_ALREADY_TYPEDEFED
-# define PIXEL_ALREADY_TYPEDEFED /* Sigh, Xmu/Drawing.h needs this... */
-# endif
-#endif
-
-#ifdef HAVE_XMU
-# ifndef VMS
-# include <X11/Xmu/Drawing.h>
-#else /* VMS */
-# include <Xmu/Drawing.h>
-# endif /* VMS */
-#endif
-
#include "images/som.xbm"
static Display *dpy;
}
}
-static void
-read_bitmap (char *bitmap_name, int *widthP, int *heightP)
-{
-#ifdef HAVE_XPM
- XWindowAttributes xgwa;
- XpmAttributes xpmattrs;
- int result;
- xpmattrs.valuemask = 0;
- bitmap = 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 = XpmReadFileToPixmap (dpy, window, bitmap_name, &bitmap, 0,
- &xpmattrs);
- switch (result)
- {
- case XpmColorError:
- fprintf (stderr, "%s: warning: xpm color substitution performed\n",
- progname);
- /* fall through */
- case XpmSuccess:
- *widthP = xpmattrs.width;
- *heightP = xpmattrs.height;
- break;
- case XpmFileInvalid:
- case XpmOpenFailed:
- bitmap = 0;
- break;
- case XpmColorFailed:
- fprintf (stderr, "%s: xpm: color allocation failed\n", progname);
- exit (-1);
- case XpmNoMemory:
- fprintf (stderr, "%s: xpm: out of memory\n", progname);
- exit (-1);
- default:
- fprintf (stderr, "%s: xpm: unknown error code %d\n", progname, result);
- exit (-1);
- }
- if (! bitmap)
-#endif
-
-#ifdef HAVE_XMU
- {
- int xh, yh;
- Pixmap b2;
- bitmap = XmuLocateBitmapFile (DefaultScreenOfDisplay (dpy), bitmap_name,
- 0, 0, widthP, heightP, &xh, &yh);
- if (! bitmap)
- {
- fprintf (stderr, "%s: couldn't find bitmap %s\n", progname,
- bitmap_name);
- exit (1);
- }
- b2 = XmuCreatePixmapFromBitmap (dpy, window, bitmap, *widthP, *heightP,
- depth, fg, bg);
- XFreePixmap (dpy, bitmap);
- bitmap = b2;
- }
-#else /* !XMU */
- {
- fprintf (stderr,
- "%s: your vendor doesn't ship the standard Xmu library.\n",
- progname);
- fprintf (stderr, "\tWe can't load XBM files without it.\n");
- exit (1);
- }
-#endif /* !XMU */
-}
-
-
static Pixmap
read_screen (Display *dpy, Window window, int *widthP, int *heightP)
{
*widthP = xgwa.width;
*heightP = xgwa.height;
- grab_screen_image(xgwa.screen, window);
p = XCreatePixmap(dpy, window, *widthP, *heightP, xgwa.depth);
gcv.function = GXcopy;
gc = XCreateGC (dpy, window, GCFunction, &gcv);
- XCopyArea (dpy, window, p, gc, 0, 0, *widthP, *heightP, 0, 0);
+
+ load_random_image (xgwa.screen, window, p);
/* Reset the window's background color... */
XSetWindowBackground (dpy, window,
}
else
{
- read_bitmap (bitmap_name, &width, &height);
+ bitmap = xpm_file_to_pixmap (dpy, window, bitmap_name,
+ &width, &height, 0);
scale_up = True; /* probably? */
}
display (self);
XSync(dpy, False);
+ screenhack_handle_events (dpy);
}
static void
last_w = xgwa.width;
last_h = xgwa.height;
}
-#ifdef HAVE_XPM
if (depth != 1)
XCopyArea (dpy, pixmap, window, gc, 0, 0, size, size,
(xgwa.width-size)>>1, (xgwa.height-size)>>1);
else
-#endif
XCopyPlane (dpy, pixmap, window, gc, 0, 0, size, size,
(xgwa.width-size)>>1, (xgwa.height-size)>>1, 1);
/*
((xgwa.width-size)>>1)-1, ((xgwa.height-size)>>1)-1,
size+2, size+2);
*/
- XSync (dpy, True);
+ XSync (dpy, False);
+ screenhack_handle_events (dpy);
}
\f
char *progclass = "BlitSpin";
char *defaults [] = {
- "*background: black",
- "*foreground: white",
+ ".background: black",
+ ".foreground: white",
"*delay: 500000",
"*delay2: 500000",
"*bitmap: (default)",
while (1)
{
rotate ();
+ screenhack_handle_events (d);
if (delay2) usleep (delay2);
}
}