X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=hacks%2Fbumps.c;fp=hacks%2Fbumps.c;h=fa728e6c0a247a6ae846f272fe06176d410ead58;hb=4361b69d3178d7fc98d0388f9a223af6c2651aba;hp=60de04a3c9ebb87957e3b782a4f1ed942cf2a284;hpb=d6b0217f2417bd19187f0ebc389d6c5c2233b11c;p=xscreensaver
diff --git a/hacks/bumps.c b/hacks/bumps.c
index 60de04a3..fa728e6c 100644
--- a/hacks/bumps.c
+++ b/hacks/bumps.c
@@ -20,12 +20,14 @@
* Essentially, it 3D-izes your desktop, based on color intensity.
*
* Modification History:
- * [10/01/99] - Shane Smit: Creation
- * [10/08/99] - Shane Smit: Port to C. (Ick)
- * [03/08/02] - Shane Smit: New movement code.
- * [09/12/02] - Shane Smit: MIT-SHM XImages.
- * Thanks to Kennett Galbraith
- * for code optimization.
+ * [10/01/1999] - Shane Smit: Creation
+ * [10/08/1999] - Shane Smit: Port to C. (Ick)
+ * [03/08/2002] - Shane Smit: New movement code.
+ * [09/12/2002] - Shane Smit: MIT-SHM XImages.
+ * Thanks to Kennett Galbraith
+ * for code optimization.
+ * [10/09/2016] - Dave Odell: Updated for new xshm.c.
+ * Y2K compliance.
*/
@@ -33,10 +35,7 @@
#include
#include
#include "screenhack.h"
-
-#ifdef HAVE_XSHM_EXTENSION
#include "xshm.h"
-#endif /* HAVE_XSHM_EXTENSION */
/* Defines: */
@@ -114,10 +113,7 @@ typedef struct
XColor *xColors;
unsigned long *aColors;
XImage *pXImage;
-#ifdef HAVE_XSHM_EXTENSION
XShmSegmentInfo XShmInfo;
- Bool bUseShm;
-#endif /* HAVE_XSHM_EXTENSION */
uint8_t nColorCount; /* Number of colors used. */
uint8_t bytesPerPixel;
@@ -265,7 +261,6 @@ static void CreateBumps( SBumps *pBumps, Display *dpy, Window NewWin )
pBumps->dpy = dpy;
pBumps->Win = NewWin;
pBumps->screen = XWinAttribs.screen;
- pBumps->pXImage = NULL;
iDiameter = ( ( pBumps->iWinWidth < pBumps->iWinHeight ) ? pBumps->iWinWidth : pBumps->iWinHeight ) / 2;
@@ -273,26 +268,8 @@ static void CreateBumps( SBumps *pBumps, Display *dpy, Window NewWin )
constraining it to be a multiple of 8 seems to fix it. */
iDiameter = ((iDiameter+7)/8)*8;
-#ifdef HAVE_XSHM_EXTENSION
- pBumps->bUseShm = get_boolean_resource(dpy, "useSHM", "Boolean" );
-
- if( pBumps->bUseShm )
- {
- pBumps->pXImage = create_xshm_image( pBumps->dpy, XWinAttribs.visual, XWinAttribs.depth,
- ZPixmap, NULL, &pBumps->XShmInfo, iDiameter, iDiameter );
- if( !pBumps->pXImage )
- {
- fprintf( stderr, "%s: Unable to create XShmImage.\n", progname );
- pBumps->bUseShm = False;
- }
- }
-#endif /* HAVE_XSHM_EXTENSION */
- if( !pBumps->pXImage )
- {
- pBumps->pXImage = XCreateImage( pBumps->dpy, XWinAttribs.visual, XWinAttribs.depth,
- ZPixmap, 0, NULL, iDiameter, iDiameter, BitmapPad( pBumps->dpy ), 0 );
- pBumps->pXImage->data = malloc( pBumps->pXImage->bytes_per_line * pBumps->pXImage->height * sizeof(int8_t) );
- }
+ pBumps->pXImage = create_xshm_image( pBumps->dpy, XWinAttribs.visual, XWinAttribs.depth,
+ ZPixmap, &pBumps->XShmInfo, iDiameter, iDiameter );
/* For speed, access the XImage data directly using my own PutPixel routine. */
switch( pBumps->pXImage->bits_per_pixel )
@@ -319,12 +296,7 @@ static void CreateBumps( SBumps *pBumps, Display *dpy, Window NewWin )
default:
fprintf( stderr, "%s: Unknown XImage depth.", progname );
-#ifdef HAVE_XSHM_EXTENSION
- if( pBumps->bUseShm )
- destroy_xshm_image( pBumps->dpy, pBumps->pXImage, &pBumps->XShmInfo );
- else
-#endif /* HAVE_XSHM_EXTENSION */
- XDestroyImage( pBumps->pXImage );
+ destroy_xshm_image( pBumps->dpy, pBumps->pXImage, &pBumps->XShmInfo );
exit( 1 );
}
@@ -623,14 +595,8 @@ static void Execute( SBumps *pBumps )
nY -= ( nLightYPos + nY ) - pBumps->iWinHeight;
}
-#ifdef HAVE_XSHM_EXTENSION
- if( pBumps->bUseShm )
- XShmPutImage( pBumps->dpy, pBumps->Win, pBumps->GraphicsContext, pBumps->pXImage, iLightX, iLightY, nLightXPos, nLightYPos,
- nX, nY, False);
- else
-#endif /* HAVE_XSHM_EXTENSION */
- XPutImage( pBumps->dpy, pBumps->Win, pBumps->GraphicsContext, pBumps->pXImage, iLightX, iLightY, nLightXPos, nLightYPos,
- nX, nY );
+ put_xshm_image( pBumps->dpy, pBumps->Win, pBumps->GraphicsContext, pBumps->pXImage, iLightX, iLightY, nLightXPos, nLightYPos,
+ nX, nY, &pBumps->XShmInfo);
}
@@ -642,12 +608,7 @@ static void DestroyBumps( SBumps *pBumps )
DestroySpotLight( &pBumps->SpotLight );
free( pBumps->aColors );
free( pBumps->aBumpMap );
-#ifdef HAVE_XSHM_EXTENSION
- if( pBumps->bUseShm )
- destroy_xshm_image( pBumps->dpy, pBumps->pXImage, &pBumps->XShmInfo );
- else
-#endif /* HAVE_XSHM_EXTENSION */
- XDestroyImage( pBumps->pXImage );
+ destroy_xshm_image( pBumps->dpy, pBumps->pXImage, &pBumps->XShmInfo );
}