X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=utils%2Fxshm.c;h=a05601503663f9473927d9a20b791f52ecf00846;hb=2d04c4f22466851aedb6ed0f2919d148f726b889;hp=c9498e5b0e18e39891744e845c27a6738db8afaa;hpb=59ac4e9a0de290e4275a7bbb890ad16abd09d68f;p=xscreensaver diff --git a/utils/xshm.c b/utils/xshm.c index c9498e5b..a0560150 100644 --- a/utils/xshm.c +++ b/utils/xshm.c @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998 +/* xscreensaver, Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998, 2001 * by Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its @@ -21,9 +21,7 @@ needed, anyway.) If you don't have man pages for this extension, see - http://www.physik.uni-regensburg.de/~scs22156/sofie-0.2/mit-shm.html - or in the R6 sources as "xc/doc/specs/Xext/mit-shm.ms", for example, - ftp://ftp.x.org/pub/R6.4/xc/doc/specs/Xext/mit-shm.ms + http://www.x.org/X11R6.8.1/docs/Xext/ (This document seems not to ever remain available on the web in one place for very long; you can search for it by the title, "MIT-SHM -- The MIT @@ -189,4 +187,43 @@ create_xshm_image (Display *dpy, Visual *visual, return image; } + +void +destroy_xshm_image (Display *dpy, XImage *image, XShmSegmentInfo *shm_info) +{ + Status status; + + CATCH_X_ERROR(dpy); + status = XShmDetach (dpy, shm_info); + UNCATCH_X_ERROR(dpy); + if (shm_got_x_error) + status = False; + if (!status) + fprintf (stderr, "%s: XShmDetach failed!\n", progname); +#ifdef DEBUG + else + fprintf (stderr, "%s: XShmDetach(dpy, shm_info) ==> True\n", progname); +#endif + + XDestroyImage (image); + XSync(dpy, False); + + status = shmdt (shm_info->shmaddr); + + if (status != 0) + { + char buf[1024]; + sprintf (buf, "%s: shmdt(0x%lx) failed", progname, + (unsigned long) shm_info->shmaddr); + perror(buf); + } +#ifdef DEBUG + else + fprintf (stderr, "%s: shmdt(shm_info->shmaddr) ==> 0\n", progname); +#endif + + XSync(dpy, False); +} + + #endif /* HAVE_XSHM_EXTENSION */