Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!snorkelwacker!paperboy!husc6!metatron!hallinan From: hallinan@metatron.harvard.edu (Peter Hallinan) Newsgroups: comp.windows.x Subject: standard colormap utility Message-ID: <4153@husc6.harvard.edu> Date: 12 Sep 90 15:19:37 GMT Sender: news@husc6.harvard.edu Reply-To: hallinan@metatron.UUCP (Peter Hallinan) Distribution: usa Organization: Robotics Group - Harvard University Division of Applied Science Lines: 66 I am trying to write a utility to change the standard colormap RGB_DEFAULT_MAP. My reason for doing this is simply that one colormap can accomodate all my applications if it is set up correctly, allowing all applications to display correct colors simultaneously. My intention is to call the utility immediately after logging in on DecStations running DECWindows, and immediately after starting X on Sun Workstations, i.e. before starting any X applications such as xterm. I would like RGB_DEFAULT_MAP to have the following structure: 192 read-only color cells - my choice 64 unallocated color cells - for various applications, eg xterm The Xlib guide suggests using XSetStandardColormap(), but the code sequence it describes does not clearly explain how to set RGB_DEFAULT_MAP (it seems to be a special case), nor does it indicate exactly when XSetStandardColormap() should be called. So now I am stuck. A sketch of my (incorrect) code for this utility follows. I would very much appreciate any comments and/or corrections. Thanks in advance, Peter Hallinan hallinan@gramian.harvard.edu /****************************************************************************/ main() { int i, scr, depth; Display *dsp; Window root; XVisualInfo vinfo; XColor cdef; Colormap cmap; XStandardColormap stdcmap; dsp = XOpenDisplay (getenv("DISPLAY")); scr = DefaultScreen (dsp); root = DefaultRootWindow(dsp); depth = DisplayPlanes (dsp, scr); /* create new color map w/ 192 read-only cells */ XMatchVisualInfo (dsp, scr, depth, PseudoColor, &vinfo); cmap = XCreateColormap (dsp,root,vinfo.visual,AllocNone); /* allocate the new read-only default colors */ for (i = 0; i < 192; i++) { cdef.pixel = i; cdef.red = xxx; etc XAllocColor (dsp, cmap, &cdef); } /* fill in XStandardColormap structure */ stdcmap.colormap = cmap; etc /* somehow replace the old RGB_DEFAULT_MAP */ XGrabServer (dsp); XChangeProperty (dsp, root, XA_RGB_DEFAULT_MAP, XA_RGB_COLOR_MAP, 32, PropModeReplace, (char *)&stdcmap, 9); XSetStandardColormap (dsp, root, &stdcmap, XA_RGB_DEFAULT_MAP); XSetCloseDownMode (dsp, RetainPermanent); XUngrabServer (dsp); } Peter W. Hallinan Aiken 229 hallinan@gramian.harvard.edu Harvard University Cambridge, MA 02138