Blame src/DelCmap.c

Packit Service 2b1f13
/*
Packit Service 2b1f13
Packit Service 2b1f13
Copyright 1989, 1998  The Open Group
Packit Service 2b1f13
Packit Service 2b1f13
Permission to use, copy, modify, distribute, and sell this software and its
Packit Service 2b1f13
documentation for any purpose is hereby granted without fee, provided that
Packit Service 2b1f13
the above copyright notice appear in all copies and that both that
Packit Service 2b1f13
copyright notice and this permission notice appear in supporting
Packit Service 2b1f13
documentation.
Packit Service 2b1f13
Packit Service 2b1f13
The above copyright notice and this permission notice shall be included in
Packit Service 2b1f13
all copies or substantial portions of the Software.
Packit Service 2b1f13
Packit Service 2b1f13
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Packit Service 2b1f13
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Packit Service 2b1f13
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
Packit Service 2b1f13
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
Packit Service 2b1f13
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
Packit Service 2b1f13
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Packit Service 2b1f13
Packit Service 2b1f13
Except as contained in this notice, the name of The Open Group shall not be
Packit Service 2b1f13
used in advertising or otherwise to promote the sale, use or other dealings
Packit Service 2b1f13
in this Software without prior written authorization from The Open Group.
Packit Service 2b1f13
Packit Service 2b1f13
*/
Packit Service 2b1f13
Packit Service 2b1f13
/*
Packit Service 2b1f13
 * Author:  Donna Converse, MIT X Consortium
Packit Service 2b1f13
 */
Packit Service 2b1f13
Packit Service 2b1f13
#ifdef HAVE_CONFIG_H
Packit Service 2b1f13
#include <config.h>
Packit Service 2b1f13
#endif
Packit Service 2b1f13
#include <X11/Xlib.h>
Packit Service 2b1f13
#include <X11/Xutil.h>
Packit Service 2b1f13
#include <X11/Xmu/StdCmap.h>
Packit Service 2b1f13
Packit Service 2b1f13
/* To remove any standard colormap property, use XmuDeleteStandardColormap().
Packit Service 2b1f13
 * XmuDeleteStandardColormap() will remove the specified property from the
Packit Service 2b1f13
 * specified screen, releasing any resources used by the colormap(s) of the
Packit Service 2b1f13
 * property if possible.
Packit Service 2b1f13
 */
Packit Service 2b1f13
Packit Service 2b1f13
void
Packit Service 2b1f13
XmuDeleteStandardColormap(Display *dpy, int screen, Atom property)
Packit Service 2b1f13
     /* dpy;		- specifies the X server to connect to
Packit Service 2b1f13
      * screen		- specifies the screen of the display
Packit Service 2b1f13
      * property	- specifies the standard colormap property
Packit Service 2b1f13
      */
Packit Service 2b1f13
{
Packit Service 2b1f13
    XStandardColormap	*stdcmaps, *s;
Packit Service 2b1f13
    int			count = 0;
Packit Service 2b1f13
Packit Service 2b1f13
    if (XGetRGBColormaps(dpy, RootWindow(dpy, screen), &stdcmaps, &count,
Packit Service 2b1f13
			 property))
Packit Service 2b1f13
    {
Packit Service 2b1f13
	for (s=stdcmaps; count > 0; count--, s++) {
Packit Service 2b1f13
	    if ((s->killid == ReleaseByFreeingColormap) &&
Packit Service 2b1f13
		(s->colormap != None) &&
Packit Service 2b1f13
		(s->colormap != DefaultColormap(dpy, screen)))
Packit Service 2b1f13
		XFreeColormap(dpy, s->colormap);
Packit Service 2b1f13
	    else if (s->killid != None)
Packit Service 2b1f13
		XKillClient(dpy, s->killid);
Packit Service 2b1f13
	}
Packit Service 2b1f13
	XDeleteProperty(dpy, RootWindow(dpy, screen), property);
Packit Service 2b1f13
	XFree((char *) stdcmaps);
Packit Service 2b1f13
	XSync(dpy, False);
Packit Service 2b1f13
    }
Packit Service 2b1f13
}
Packit Service 2b1f13