1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
30 #include "gdkprivate-x11.h"
32 #define GDK_COLORMAP_PRIVATE_DATA(cmap) ((GdkColormapPrivateX11 *) GDK_COLORMAP (cmap)->windowing_data)
34 static gint gdk_colormap_match_color (GdkColormap *cmap,
36 const gchar *available);
37 static void gdk_colormap_add (GdkColormap *cmap);
38 static void gdk_colormap_remove (GdkColormap *cmap);
39 static guint gdk_colormap_hash (Colormap *cmap);
40 static gint gdk_colormap_cmp (Colormap *a,
43 static void gdk_colormap_init (GdkColormap *colormap);
44 static void gdk_colormap_class_init (GdkColormapClass *klass);
45 static void gdk_colormap_finalize (GObject *object);
47 static gpointer parent_class = NULL;
49 static GHashTable *colormap_hash = NULL;
52 gdk_colormap_get_type (void)
54 static GType object_type = 0;
58 static const GTypeInfo object_info =
60 sizeof (GdkColormapClass),
62 (GBaseFinalizeFunc) NULL,
63 (GClassInitFunc) gdk_colormap_class_init,
64 NULL, /* class_finalize */
65 NULL, /* class_data */
68 (GInstanceInitFunc) gdk_colormap_init,
71 object_type = g_type_register_static (G_TYPE_OBJECT,
80 gdk_colormap_init (GdkColormap *colormap)
82 GdkColormapPrivateX11 *private;
84 private = g_new (GdkColormapPrivateX11, 1);
86 colormap->windowing_data = private;
88 private->xdisplay = gdk_display;
90 private->last_sync_time = 0;
94 colormap->colors = NULL;
98 gdk_colormap_class_init (GdkColormapClass *klass)
100 GObjectClass *object_class = G_OBJECT_CLASS (klass);
102 parent_class = g_type_class_peek_parent (klass);
104 object_class->finalize = gdk_colormap_finalize;
108 gdk_colormap_finalize (GObject *object)
110 GdkColormap *colormap = GDK_COLORMAP (object);
111 GdkColormapPrivateX11 *private = GDK_COLORMAP_PRIVATE_DATA (colormap);
113 gdk_colormap_remove (colormap);
115 XFreeColormap (private->xdisplay, private->xcolormap);
118 g_hash_table_destroy (private->hash);
120 g_free (private->info);
121 g_free (colormap->colors);
123 G_OBJECT_CLASS (parent_class)->finalize (object);
127 gdk_colormap_new (GdkVisual *visual,
128 gboolean private_cmap)
130 GdkColormap *colormap;
131 GdkColormapPrivateX11 *private;
136 /* FIXME when object properties settle down, there needs to be some
137 * kind of default construction (and construct-only arguments)
140 g_return_val_if_fail (visual != NULL, NULL);
142 colormap = g_object_new (gdk_colormap_get_type (), NULL);
143 private = GDK_COLORMAP_PRIVATE_DATA (colormap);
145 colormap->visual = visual;
147 xvisual = ((GdkVisualPrivate*) visual)->xvisual;
149 colormap->size = visual->colormap_size;
151 switch (visual->type)
153 case GDK_VISUAL_GRAYSCALE:
154 case GDK_VISUAL_PSEUDO_COLOR:
155 private->info = g_new0 (GdkColorInfo, colormap->size);
156 colormap->colors = g_new (GdkColor, colormap->size);
158 private->hash = g_hash_table_new ((GHashFunc) gdk_color_hash,
159 (GCompareFunc) gdk_color_equal);
161 private->private_val = private_cmap;
162 private->xcolormap = XCreateColormap (private->xdisplay, gdk_root_window,
163 xvisual, (private_cmap) ? (AllocAll) : (AllocNone));
167 XColor *default_colors;
169 default_colors = g_new (XColor, colormap->size);
171 for (i = 0; i < colormap->size; i++)
172 default_colors[i].pixel = i;
174 XQueryColors (private->xdisplay,
175 DefaultColormap (private->xdisplay, gdk_screen),
176 default_colors, colormap->size);
178 for (i = 0; i < colormap->size; i++)
180 colormap->colors[i].pixel = default_colors[i].pixel;
181 colormap->colors[i].red = default_colors[i].red;
182 colormap->colors[i].green = default_colors[i].green;
183 colormap->colors[i].blue = default_colors[i].blue;
186 gdk_colormap_change (colormap, colormap->size);
188 g_free (default_colors);
192 case GDK_VISUAL_DIRECT_COLOR:
193 private->private_val = TRUE;
194 private->xcolormap = XCreateColormap (private->xdisplay, gdk_root_window,
196 colormap->colors = g_new (GdkColor, colormap->size);
198 size = 1 << visual->red_prec;
199 for (i = 0; i < size; i++)
200 colormap->colors[i].red = i * 65535 / (size - 1);
202 size = 1 << visual->green_prec;
203 for (i = 0; i < size; i++)
204 colormap->colors[i].green = i * 65535 / (size - 1);
206 size = 1 << visual->blue_prec;
207 for (i = 0; i < size; i++)
208 colormap->colors[i].blue = i * 65535 / (size - 1);
210 gdk_colormap_change (colormap, colormap->size);
213 case GDK_VISUAL_STATIC_GRAY:
214 case GDK_VISUAL_STATIC_COLOR:
215 case GDK_VISUAL_TRUE_COLOR:
216 private->private_val = FALSE;
217 private->xcolormap = XCreateColormap (private->xdisplay, gdk_root_window,
222 gdk_colormap_add (colormap);
227 #define MIN_SYNC_TIME 2
230 gdk_colormap_sync (GdkColormap *colormap,
234 GdkColormapPrivateX11 *private = GDK_COLORMAP_PRIVATE_DATA (colormap);
239 g_return_if_fail (GDK_IS_COLORMAP (colormap));
241 current_time = time (NULL);
242 if (!force && ((current_time - private->last_sync_time) < MIN_SYNC_TIME))
245 private->last_sync_time = current_time;
248 xpalette = g_new (XColor, colormap->size);
250 for (i = 0; i < colormap->size; i++)
252 if (private->info[i].ref_count == 0)
254 xpalette[nlookup].pixel = i;
255 xpalette[nlookup].red = 0;
256 xpalette[nlookup].green = 0;
257 xpalette[nlookup].blue = 0;
262 XQueryColors (gdk_display, private->xcolormap, xpalette, nlookup);
264 for (i = 0; i < nlookup; i++)
266 gulong pixel = xpalette[i].pixel;
267 colormap->colors[pixel].pixel = pixel;
268 colormap->colors[pixel].red = xpalette[i].red;
269 colormap->colors[pixel].green = xpalette[i].green;
270 colormap->colors[pixel].blue = xpalette[i].blue;
278 gdk_colormap_get_system (void)
280 static GdkColormap *colormap = NULL;
281 GdkColormapPrivateX11 *private;
285 colormap = g_object_new (gdk_colormap_get_type (), NULL);
286 private = GDK_COLORMAP_PRIVATE_DATA (colormap);
288 private->xdisplay = gdk_display;
289 private->xcolormap = DefaultColormap (gdk_display, gdk_screen);
290 colormap->visual = gdk_visual_get_system ();
291 private->private_val = FALSE;
293 private->hash = NULL;
294 private->last_sync_time = 0;
295 private->info = NULL;
297 colormap->colors = NULL;
298 colormap->size = colormap->visual->colormap_size;
300 if ((colormap->visual->type == GDK_VISUAL_GRAYSCALE) ||
301 (colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR))
303 private->info = g_new0 (GdkColorInfo, colormap->size);
304 colormap->colors = g_new (GdkColor, colormap->size);
306 private->hash = g_hash_table_new ((GHashFunc) gdk_color_hash,
307 (GCompareFunc) gdk_color_equal);
309 gdk_colormap_sync (colormap, TRUE);
312 gdk_colormap_add (colormap);
319 gdk_colormap_get_system_size (void)
321 return DisplayCells (gdk_display, gdk_screen);
325 gdk_colormap_change (GdkColormap *colormap,
328 GdkColormapPrivateX11 *private;
336 g_return_if_fail (GDK_IS_COLORMAP (colormap));
338 palette = g_new (XColor, ncolors);
340 private = GDK_COLORMAP_PRIVATE_DATA (colormap);
341 switch (colormap->visual->type)
343 case GDK_VISUAL_GRAYSCALE:
344 case GDK_VISUAL_PSEUDO_COLOR:
345 for (i = 0; i < ncolors; i++)
347 palette[i].pixel = colormap->colors[i].pixel;
348 palette[i].red = colormap->colors[i].red;
349 palette[i].green = colormap->colors[i].green;
350 palette[i].blue = colormap->colors[i].blue;
351 palette[i].flags = DoRed | DoGreen | DoBlue;
354 XStoreColors (private->xdisplay, private->xcolormap, palette, ncolors);
357 case GDK_VISUAL_DIRECT_COLOR:
358 visual = colormap->visual;
360 shift = visual->red_shift;
361 max_colors = 1 << visual->red_prec;
362 size = (ncolors < max_colors) ? (ncolors) : (max_colors);
364 for (i = 0; i < size; i++)
366 palette[i].pixel = i << shift;
367 palette[i].red = colormap->colors[i].red;
368 palette[i].flags = DoRed;
371 XStoreColors (private->xdisplay, private->xcolormap, palette, size);
373 shift = visual->green_shift;
374 max_colors = 1 << visual->green_prec;
375 size = (ncolors < max_colors) ? (ncolors) : (max_colors);
377 for (i = 0; i < size; i++)
379 palette[i].pixel = i << shift;
380 palette[i].green = colormap->colors[i].green;
381 palette[i].flags = DoGreen;
384 XStoreColors (private->xdisplay, private->xcolormap, palette, size);
386 shift = visual->blue_shift;
387 max_colors = 1 << visual->blue_prec;
388 size = (ncolors < max_colors) ? (ncolors) : (max_colors);
390 for (i = 0; i < size; i++)
392 palette[i].pixel = i << shift;
393 palette[i].blue = colormap->colors[i].blue;
394 palette[i].flags = DoBlue;
397 XStoreColors (private->xdisplay, private->xcolormap, palette, size);
408 gdk_colors_alloc (GdkColormap *colormap,
415 GdkColormapPrivateX11 *private;
419 g_return_val_if_fail (GDK_IS_COLORMAP (colormap), 0);
421 private = GDK_COLORMAP_PRIVATE_DATA (colormap);
423 return_val = XAllocColorCells (private->xdisplay, private->xcolormap,
424 contiguous, planes, nplanes, pixels, npixels);
428 for (i=0; i<npixels; i++)
430 private->info[pixels[i]].ref_count++;
431 private->info[pixels[i]].flags |= GDK_COLOR_WRITEABLE;
435 return return_val != 0;
439 gdk_color_parse (const gchar *spec,
446 g_return_val_if_fail (spec != NULL, FALSE);
447 g_return_val_if_fail (color != NULL, FALSE);
449 xcolormap = DefaultColormap (gdk_display, gdk_screen);
451 if (XParseColor (gdk_display, xcolormap, spec, &xcolor))
454 color->red = xcolor.red;
455 color->green = xcolor.green;
456 color->blue = xcolor.blue;
464 /* This is almost identical to gdk_colormap_free_colors.
468 gdk_colors_free (GdkColormap *colormap,
473 GdkColormapPrivateX11 *private;
478 g_return_if_fail (GDK_IS_COLORMAP (colormap));
479 g_return_if_fail (in_pixels != NULL);
481 private = GDK_COLORMAP_PRIVATE_DATA (colormap);
483 if ((colormap->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
484 (colormap->visual->type != GDK_VISUAL_GRAYSCALE))
487 pixels = g_new (gulong, in_npixels);
489 for (i=0; i<in_npixels; i++)
491 gulong pixel = in_pixels[i];
493 if (private->info[pixel].ref_count)
495 private->info[pixel].ref_count--;
497 if (private->info[pixel].ref_count == 0)
499 pixels[npixels++] = pixel;
500 if (!(private->info[pixel].flags & GDK_COLOR_WRITEABLE))
501 g_hash_table_remove (private->hash, &colormap->colors[pixel]);
502 private->info[pixel].flags = 0;
508 XFreeColors (private->xdisplay, private->xcolormap,
509 pixels, npixels, planes);
513 /* This is almost identical to gdk_colors_free.
517 gdk_colormap_free_colors (GdkColormap *colormap,
521 GdkColormapPrivateX11 *private;
526 g_return_if_fail (GDK_IS_COLORMAP (colormap));
527 g_return_if_fail (colors != NULL);
529 private = GDK_COLORMAP_PRIVATE_DATA (colormap);
531 if ((colormap->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
532 (colormap->visual->type != GDK_VISUAL_GRAYSCALE))
535 pixels = g_new (gulong, ncolors);
537 for (i=0; i<ncolors; i++)
539 gulong pixel = colors[i].pixel;
541 if (private->info[pixel].ref_count)
543 private->info[pixel].ref_count--;
545 if (private->info[pixel].ref_count == 0)
547 pixels[npixels++] = pixel;
548 if (!(private->info[pixel].flags & GDK_COLOR_WRITEABLE))
549 g_hash_table_remove (private->hash, &colormap->colors[pixel]);
550 private->info[pixel].flags = 0;
556 XFreeColors (private->xdisplay, private->xcolormap,
562 /********************
564 ********************/
566 /* Try to allocate a single color using XAllocColor. If it succeeds,
567 * cache the result in our colormap, and store in ret.
570 gdk_colormap_alloc1 (GdkColormap *colormap,
574 GdkColormapPrivateX11 *private;
577 private = GDK_COLORMAP_PRIVATE_DATA (colormap);
579 xcolor.red = color->red;
580 xcolor.green = color->green;
581 xcolor.blue = color->blue;
582 xcolor.pixel = color->pixel;
583 xcolor.flags = DoRed | DoGreen | DoBlue;
585 if (XAllocColor (private->xdisplay, private->xcolormap, &xcolor))
587 ret->pixel = xcolor.pixel;
588 ret->red = xcolor.red;
589 ret->green = xcolor.green;
590 ret->blue = xcolor.blue;
592 if (ret->pixel < colormap->size)
594 if (private->info[ret->pixel].ref_count) /* got a duplicate */
596 XFreeColors (private->xdisplay, private->xcolormap,
601 colormap->colors[ret->pixel] = *color;
602 colormap->colors[ret->pixel].pixel = ret->pixel;
603 private->info[ret->pixel].ref_count = 1;
605 g_hash_table_insert (private->hash,
606 &colormap->colors[ret->pixel],
607 &colormap->colors[ret->pixel]);
619 gdk_colormap_alloc_colors_writeable (GdkColormap *colormap,
626 GdkColormapPrivateX11 *private;
631 private = GDK_COLORMAP_PRIVATE_DATA (colormap);
633 if (private->private_val)
636 for (i=0; i<ncolors; i++)
638 while ((index < colormap->size) && (private->info[index].ref_count != 0))
641 if (index < colormap->size)
643 colors[i].pixel = index;
645 private->info[index].ref_count++;
646 private->info[i].flags |= GDK_COLOR_WRITEABLE;
655 pixels = g_new (gulong, ncolors);
656 /* Allocation of a writeable color cells */
658 status = XAllocColorCells (private->xdisplay, private->xcolormap,
659 FALSE, NULL, 0, pixels, ncolors);
662 for (i=0; i<ncolors; i++)
664 colors[i].pixel = pixels[i];
665 private->info[pixels[i]].ref_count++;
666 private->info[pixels[i]].flags |= GDK_COLOR_WRITEABLE;
672 return status ? ncolors : 0;
677 gdk_colormap_alloc_colors_private (GdkColormap *colormap,
684 GdkColormapPrivateX11 *private;
686 XColor *store = g_new (XColor, ncolors);
690 private = GDK_COLORMAP_PRIVATE_DATA (colormap);
693 /* First, store the colors we have room for */
696 for (i=0; i<ncolors; i++)
700 while ((index < colormap->size) && (private->info[index].ref_count != 0))
703 if (index < colormap->size)
705 store[nstore].red = colors[i].red;
706 store[nstore].blue = colors[i].blue;
707 store[nstore].green = colors[i].green;
708 store[nstore].pixel = index;
713 colors[i].pixel = index;
714 private->info[index].ref_count++;
721 XStoreColors (private->xdisplay, private->xcolormap, store, nstore);
724 if (nremaining > 0 && best_match)
726 /* Get best matches for remaining colors */
728 gchar *available = g_new (gchar, colormap->size);
729 for (i = 0; i < colormap->size; i++)
732 for (i=0; i<ncolors; i++)
736 index = gdk_colormap_match_color (colormap,
741 colors[i] = colormap->colors[index];
742 private->info[index].ref_count++;
752 return (ncolors - nremaining);
756 gdk_colormap_alloc_colors_shared (GdkColormap *colormap,
763 GdkColormapPrivateX11 *private;
768 private = GDK_COLORMAP_PRIVATE_DATA (colormap);
771 for (i=0; i<ncolors; i++)
775 if (gdk_colormap_alloc1 (colormap, &colors[i], &colors[i]))
783 if (nremaining > 0 && best_match)
785 gchar *available = g_new (gchar, colormap->size);
786 for (i = 0; i < colormap->size; i++)
787 available[i] = ((private->info[i].ref_count == 0) ||
788 !(private->info[i].flags && GDK_COLOR_WRITEABLE));
789 gdk_colormap_sync (colormap, FALSE);
791 while (nremaining > 0)
793 for (i=0; i<ncolors; i++)
797 index = gdk_colormap_match_color (colormap, &colors[i], available);
800 if (private->info[index].ref_count)
802 private->info[index].ref_count++;
803 colors[i] = colormap->colors[index];
809 if (gdk_colormap_alloc1 (colormap,
810 &colormap->colors[index],
819 available[index] = FALSE;
827 success[i] = 2; /* flag as permanent failure */
835 /* Change back the values we flagged as permanent failures */
838 for (i=0; i<ncolors; i++)
841 nremaining = nfailed;
844 return (ncolors - nremaining);
848 gdk_colormap_alloc_colors_pseudocolor (GdkColormap *colormap,
855 GdkColormapPrivateX11 *private;
856 GdkColor *lookup_color;
860 private = GDK_COLORMAP_PRIVATE_DATA (colormap);
862 /* Check for an exact match among previously allocated colors */
864 for (i=0; i<ncolors; i++)
868 lookup_color = g_hash_table_lookup (private->hash, &colors[i]);
871 private->info[lookup_color->pixel].ref_count++;
872 colors[i].pixel = lookup_color->pixel;
880 /* If that failed, we try to allocate a new color, or approxmiate
881 * with what we can get if best_match is TRUE.
885 if (private->private_val)
886 return gdk_colormap_alloc_colors_private (colormap, colors, ncolors, writeable, best_match, success);
888 return gdk_colormap_alloc_colors_shared (colormap, colors, ncolors, writeable, best_match, success);
895 gdk_colormap_alloc_colors (GdkColormap *colormap,
902 GdkColormapPrivateX11 *private;
908 g_return_val_if_fail (GDK_IS_COLORMAP (colormap), FALSE);
909 g_return_val_if_fail (colors != NULL, FALSE);
911 private = GDK_COLORMAP_PRIVATE_DATA (colormap);
913 for (i=0; i<ncolors; i++)
918 switch (colormap->visual->type)
920 case GDK_VISUAL_PSEUDO_COLOR:
921 case GDK_VISUAL_GRAYSCALE:
923 return gdk_colormap_alloc_colors_writeable (colormap, colors, ncolors,
924 writeable, best_match, success);
926 return gdk_colormap_alloc_colors_pseudocolor (colormap, colors, ncolors,
927 writeable, best_match, success);
930 case GDK_VISUAL_DIRECT_COLOR:
931 case GDK_VISUAL_TRUE_COLOR:
932 visual = colormap->visual;
934 for (i=0; i<ncolors; i++)
936 colors[i].pixel = (((colors[i].red >> (16 - visual->red_prec)) << visual->red_shift) +
937 ((colors[i].green >> (16 - visual->green_prec)) << visual->green_shift) +
938 ((colors[i].blue >> (16 - visual->blue_prec)) << visual->blue_shift));
943 case GDK_VISUAL_STATIC_GRAY:
944 case GDK_VISUAL_STATIC_COLOR:
945 for (i=0; i<ncolors; i++)
947 xcolor.red = colors[i].red;
948 xcolor.green = colors[i].green;
949 xcolor.blue = colors[i].blue;
950 xcolor.pixel = colors[i].pixel;
951 xcolor.flags = DoRed | DoGreen | DoBlue;
953 if (XAllocColor (private->xdisplay, private->xcolormap, &xcolor))
955 colors[i].pixel = xcolor.pixel;
967 gdk_color_change (GdkColormap *colormap,
970 GdkColormapPrivateX11 *private;
973 g_return_val_if_fail (GDK_IS_COLORMAP (colormap), FALSE);
974 g_return_val_if_fail (color != NULL, FALSE);
976 xcolor.pixel = color->pixel;
977 xcolor.red = color->red;
978 xcolor.green = color->green;
979 xcolor.blue = color->blue;
980 xcolor.flags = DoRed | DoGreen | DoBlue;
982 private = GDK_COLORMAP_PRIVATE_DATA (colormap);
983 XStoreColor (private->xdisplay, private->xcolormap, &xcolor);
988 /* XXX: Do not use this function until it is fixed. An X Colormap
989 * is useless unless we also have the visual.
992 gdkx_colormap_get (Colormap xcolormap)
994 GdkColormap *colormap;
995 GdkColormapPrivateX11 *private;
997 colormap = gdk_colormap_lookup (xcolormap);
1001 if (xcolormap == DefaultColormap (gdk_display, gdk_screen))
1002 return gdk_colormap_get_system ();
1004 colormap = g_object_new (gdk_colormap_get_type (), NULL);
1005 private = GDK_COLORMAP_PRIVATE_DATA (colormap);
1007 private->xdisplay = gdk_display;
1008 private->xcolormap = xcolormap;
1009 colormap->visual = NULL;
1010 private->private_val = TRUE;
1012 /* To do the following safely, we would have to have some way of finding
1013 * out what the size or visual of the given colormap is. It seems
1014 * X doesn't allow this
1018 for (i = 0; i < 256; i++)
1020 xpalette[i].pixel = i;
1021 xpalette[i].red = 0;
1022 xpalette[i].green = 0;
1023 xpalette[i].blue = 0;
1026 XQueryColors (gdk_display, private->xcolormap, xpalette, 256);
1028 for (i = 0; i < 256; i++)
1030 colormap->colors[i].pixel = xpalette[i].pixel;
1031 colormap->colors[i].red = xpalette[i].red;
1032 colormap->colors[i].green = xpalette[i].green;
1033 colormap->colors[i].blue = xpalette[i].blue;
1037 colormap->colors = NULL;
1040 gdk_colormap_add (colormap);
1047 gdk_colormap_match_color (GdkColormap *cmap,
1049 const gchar *available)
1053 gint rdiff, gdiff, bdiff;
1056 g_return_val_if_fail (cmap != NULL, 0);
1057 g_return_val_if_fail (color != NULL, 0);
1059 colors = cmap->colors;
1063 for (i = 0; i < cmap->size; i++)
1065 if ((!available) || (available && available[i]))
1067 rdiff = (color->red - colors[i].red);
1068 gdiff = (color->green - colors[i].green);
1069 bdiff = (color->blue - colors[i].blue);
1071 sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
1086 gdk_colormap_lookup (Colormap xcolormap)
1093 cmap = g_hash_table_lookup (colormap_hash, &xcolormap);
1098 gdk_colormap_add (GdkColormap *cmap)
1100 GdkColormapPrivateX11 *private;
1103 colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
1104 (GCompareFunc) gdk_colormap_cmp);
1106 private = GDK_COLORMAP_PRIVATE_DATA (cmap);
1108 g_hash_table_insert (colormap_hash, &private->xcolormap, cmap);
1112 gdk_colormap_remove (GdkColormap *cmap)
1114 GdkColormapPrivateX11 *private;
1117 colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
1118 (GCompareFunc) gdk_colormap_cmp);
1120 private = GDK_COLORMAP_PRIVATE_DATA (cmap);
1122 g_hash_table_remove (colormap_hash, &private->xcolormap);
1126 gdk_colormap_hash (Colormap *cmap)
1132 gdk_colormap_cmp (Colormap *a,