From http://www.jwz.org/xscreensaver/xscreensaver-5.37.tar.gz
[xscreensaver] / hacks / twang.c
index 7d52a411156bda8047298f13ba6ea15d3acf6514..ae589ad662c75a8e24fbccaf33039ecc2fafb144 100644 (file)
 
 #include <math.h>
 #include "screenhack.h"
-
-#ifdef HAVE_XSHM_EXTENSION
 #include "xshm.h"
-#endif
 
 #define FLOAT double
 
@@ -80,10 +77,7 @@ struct state {
   async_load_state *img_loader;
   Pixmap pm;
 
-  Bool useShm;         /* whether or not to use xshm */
-#ifdef HAVE_XSHM_EXTENSION
   XShmSegmentInfo shmInfo;
-#endif
 };
 
 
@@ -131,28 +125,12 @@ grabImage_done (struct state *st)
                                  st->windowWidth, st->windowHeight,
                             ~0L, ZPixmap);
 
-    if (st->workImage) XDestroyImage (st->workImage);
-    st->workImage = NULL;
-
-#ifdef HAVE_XSHM_EXTENSION
-    if (st->useShm) 
-    {
-       st->workImage = create_xshm_image (st->dpy, xwa.visual, xwa.depth,
-                                      ZPixmap, 0, &st->shmInfo, 
-                                      st->windowWidth, st->windowHeight);
-       if (!st->workImage) 
-       {
-           st->useShm = False;
-           fprintf (stderr, "create_xshm_image failed\n");
-       }
-    }
-
-    if (st->workImage == NULL)
-#endif /* HAVE_XSHM_EXTENSION */
+    if (st->workImage) destroy_xshm_image (st->dpy, st->workImage,
+                                           &st->shmInfo);
 
-       /* just use XSubImage to acquire the right visual, depth, etc;
-        * easier than the other alternatives */
-       st->workImage = XSubImage (st->sourceImage, 0, 0, st->windowWidth, st->windowHeight);
+    st->workImage = create_xshm_image (st->dpy, xwa.visual, xwa.depth,
+                                       ZPixmap, &st->shmInfo,
+                                       st->windowWidth, st->windowHeight);
 }
 
 /* set up the system */
@@ -537,14 +515,8 @@ static void renderFrame (struct state *st)
        renderTile (st, st->sortedTiles[n]);
     }
 
-#ifdef HAVE_XSHM_EXTENSION
-    if (st->useShm)
-       XShmPutImage (st->dpy, st->window, st->backgroundGC, st->workImage, 0, 0, 0, 0,
-                     st->windowWidth, st->windowHeight, False);
-    else
-#endif /* HAVE_XSHM_EXTENSION */
-       XPutImage (st->dpy, st->window, st->backgroundGC, st->workImage, 
-                  0, 0, 0, 0, st->windowWidth, st->windowHeight);
+    put_xshm_image (st->dpy, st->window, st->backgroundGC, st->workImage, 0, 0, 0, 0,
+                    st->windowWidth, st->windowHeight, &st->shmInfo);
 }
 
 /* set up the model */
@@ -734,10 +706,6 @@ static void initParams (struct state *st)
        problems = 1;
     }
 
-#ifdef HAVE_XSHM_EXTENSION
-    st->useShm = get_boolean_resource (st->dpy, "useSHM", "Boolean");
-#endif
-
     if (problems)
     {
        exit (1);