Change to the linux kernel coding style
[wmaker-crm.git] / wrlib / DelCmap.c
1 /* $XConsortium: DelCmap.c,v 1.2 94/04/17 20:15:58 converse Exp $ */
2
3 /*
4
5 Copyright (c) 1989 X Consortium
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13
14 The above copyright notice and this permission notice shall be included in
15 all copies or substantial portions of the Software.
16
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
24 Except as contained in this notice, the name of the X Consortium shall not be
25 used in advertising or otherwise to promote the sale, use or other dealings
26 in this Software without prior written authorization from the X Consortium.
27
28 */
29
30 /*
31 * Author: Donna Converse, MIT X Consortium
32 */
33
34 #include <X11/Xlib.h>
35 #include <X11/Xutil.h>
36
37 /* To remove any standard colormap property, use XmuDeleteStandardColormap().
38 * XmuDeleteStandardColormap() will remove the specified property from the
39 * specified screen, releasing any resources used by the colormap(s) of the
40 * property if possible.
41 */
42
43 void XmuDeleteStandardColormap(dpy, screen, property)
44 Display *dpy; /* specifies the X server to connect to */
45 int screen; /* specifies the screen of the display */
46 Atom property; /* specifies the standard colormap property */
47 {
48 XStandardColormap *stdcmaps, *s;
49 int count = 0;
50
51 if (XGetRGBColormaps(dpy, RootWindow(dpy, screen), &stdcmaps, &count, property)) {
52 for (s = stdcmaps; count > 0; count--, s++) {
53 if ((s->killid == ReleaseByFreeingColormap) &&
54 (s->colormap != None) && (s->colormap != DefaultColormap(dpy, screen)))
55 XFreeColormap(dpy, s->colormap);
56 else if (s->killid != None)
57 XKillClient(dpy, s->killid);
58 }
59 XDeleteProperty(dpy, RootWindow(dpy, screen), property);
60 XFree((char *)stdcmaps);
61 XSync(dpy, False);
62 }
63 }