void XSetStandardColormap( Display *dpy, Window w, XStandardColormap *cmap, Atom property) /* XA_RGB_BEST_MAP, etc. */ { Screen *sp; XStandardColormap stdcmap; sp = _XScreenOfWindow (dpy, w); if (!sp) { /* already caught the XGetGeometry error in _XScreenOfWindow */ return; } stdcmap.colormap = cmap->colormap; stdcmap.red_max = cmap->red_max; stdcmap.red_mult = cmap->red_mult; stdcmap.green_max = cmap->green_max; stdcmap.green_mult = cmap->green_mult; stdcmap.blue_max = cmap->blue_max; stdcmap.blue_mult = cmap->blue_mult; stdcmap.base_pixel = cmap->base_pixel; stdcmap.visualid = sp->root_visual->visualid; stdcmap.killid = None; /* don't know how to kill this one */ #ifdef XCMS XSetRGBColormaps (dpy, w, &stdcmap, 1, property); #endif return; }
Status XGetStandardColormap ( Display *dpy, Window w, XStandardColormap *cmap, Atom property) /* XA_RGB_BEST_MAP, etc. */ { Status stat; /* return value */ XStandardColormap *stdcmaps; /* will get malloced value */ int nstdcmaps; /* count of above */ stat = XGetRGBColormaps (dpy, w, &stdcmaps, &nstdcmaps, property); if (stat) { XStandardColormap *use; if (nstdcmaps > 1) { VisualID vid; Screen *sp = _XScreenOfWindow (dpy, w); int i; if (!sp) { if (stdcmaps) Xfree (stdcmaps); return False; } vid = sp->root_visual->visualid; for (i = 0; i < nstdcmaps; i++) { if (stdcmaps[i].visualid == vid) break; } if (i == nstdcmaps) { /* not found */ Xfree (stdcmaps); return False; } use = &stdcmaps[i]; } else { use = stdcmaps; } /* * assign only those fields which were in the pre-ICCCM version */ cmap->colormap = use->colormap; cmap->red_max = use->red_max; cmap->red_mult = use->red_mult; cmap->green_max = use->green_max; cmap->green_mult = use->green_mult; cmap->blue_max = use->blue_max; cmap->blue_mult = use->blue_mult; cmap->base_pixel = use->base_pixel; Xfree (stdcmaps); /* don't need alloced memory */ } return stat; }