home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / lib / Xmu / DelCmap.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-07-16  |  2.3 KB  |  59 lines

  1. /* $XConsortium: DelCmap.c,v 1.1 89/05/19 14:37:16 converse Exp $
  2.  * 
  3.  * Copyright 1989 by the Massachusetts Institute of Technology
  4.  *
  5.  * Permission to use, copy, modify, and distribute this software and its
  6.  * documentation for any purpose and without fee is hereby granted, provided 
  7.  * that the above copyright notice appear in all copies and that both that 
  8.  * copyright notice and this permission notice appear in supporting 
  9.  * documentation, and that the name of M.I.T. not be used in advertising
  10.  * or publicity pertaining to distribution of the software without specific, 
  11.  * written prior permission. M.I.T. makes no representations about the 
  12.  * suitability of this software for any purpose.  It is provided "as is"
  13.  * without express or implied warranty.
  14.  *
  15.  * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  16.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  17.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  18.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  19.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  20.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21.  *
  22.  * Author:  Donna Converse, MIT X Consortium
  23.  */
  24.  
  25. #include <X11/Xlib.h>
  26. #include <X11/Xutil.h>
  27.  
  28. /* To remove any standard colormap property, use XmuDeleteStandardColormap().
  29.  * XmuDeleteStandardColormap() will remove the specified property from the
  30.  * specified screen, releasing any resources used by the colormap(s) of the
  31.  * property if possible.
  32.  */
  33.  
  34. void XmuDeleteStandardColormap(dpy, screen, property)
  35.     Display    *dpy;        /* specifies the X server to connect to */
  36.     int        screen;        /* specifies the screen of the display */
  37.     Atom    property;    /* specifies the standard colormap property */
  38. {
  39.     XStandardColormap    *stdcmaps, *s;
  40.     int            count = 0;
  41.  
  42.     if (XGetRGBColormaps(dpy, RootWindow(dpy, screen), &stdcmaps, &count,
  43.              property))
  44.     {
  45.     for (s=stdcmaps; count > 0; count--, s++) {
  46.         if ((s->killid == ReleaseByFreeingColormap) &&
  47.         (s->colormap != None) &&
  48.         (s->colormap != DefaultColormap(dpy, screen)))
  49.         XFreeColormap(dpy, s->colormap);
  50.         else if (s->killid != None)
  51.         XKillClient(dpy, s->killid);
  52.     }
  53.     XDeleteProperty(dpy, RootWindow(dpy, screen), property);
  54.     XFree((char *) stdcmaps);
  55.     XSync(dpy, False);
  56.     }
  57. }
  58.  
  59.