X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fblitspin.c;h=ec31aa09875d8fe41326f4c2c37e8c66b6cb4147;hb=a94197e76a5dea5cb60542840809d6c20d0abbf3;hp=5a58062637dc7ed4b9dd680a78ad70ca52bb3e6e;hpb=c6b273ef7292ba10943694df1656b05203d7b62f;p=xscreensaver diff --git a/hacks/blitspin.c b/hacks/blitspin.c index 5a580626..ec31aa09 100644 --- a/hacks/blitspin.c +++ b/hacks/blitspin.c @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 1992-1997 Jamie Zawinski +/* xscreensaver, Copyright (c) 1992-1997 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -25,23 +25,9 @@ */ #include "screenhack.h" +#include "xpm-pixmap.h" #include -#ifdef HAVE_XPM -# include -# ifndef PIXEL_ALREADY_TYPEDEFED -# define PIXEL_ALREADY_TYPEDEFED /* Sigh, Xmu/Drawing.h needs this... */ -# endif -#endif - -#ifdef HAVE_XMU -# ifndef VMS -# include -#else /* VMS */ -# include -# endif /* VMS */ -#endif - #include "images/som.xbm" static Display *dpy; @@ -93,93 +79,6 @@ rotate (void) } } -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) { @@ -262,7 +161,8 @@ init (void) } else { - read_bitmap (bitmap_name, &width, &height); + bitmap = xpm_file_to_pixmap (dpy, window, bitmap_name, + &width, &height, 0); scale_up = True; /* probably? */ } @@ -299,6 +199,7 @@ init (void) display (self); XSync(dpy, False); + screenhack_handle_events (dpy); } static void @@ -313,12 +214,10 @@ display (Pixmap pixmap) 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); /* @@ -326,15 +225,16 @@ display (Pixmap pixmap) ((xgwa.width-size)>>1)-1, ((xgwa.height-size)>>1)-1, size+2, size+2); */ - XSync (dpy, True); + XSync (dpy, False); + screenhack_handle_events (dpy); } char *progclass = "BlitSpin"; char *defaults [] = { - "*background: black", - "*foreground: white", + ".background: black", + ".foreground: white", "*delay: 500000", "*delay2: 500000", "*bitmap: (default)", @@ -360,6 +260,7 @@ screenhack (Display *d, Window w) while (1) { rotate (); + screenhack_handle_events (d); if (delay2) usleep (delay2); } }