Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker!bloom-beacon!SHAMASH.MCRCIM.MCGILL.EDU!mouse From: mouse@SHAMASH.MCRCIM.MCGILL.EDU (der Mouse) Newsgroups: comp.windows.x Subject: Re: Colormaps Message-ID: <9007152249.AA13924@shamash.McRCIM.McGill.EDU> Date: 15 Jul 90 22:49:14 GMT Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 41 > I am trying to implement a 256 element PseudoColor colormap [...]. > Using the [Xlib colormap calls] I have been able to create a linear > mapping. I then use XSetWindowColormap to associate this mapping to > the toplevel application shell. Unfortunately, the colors used by > the window manager have been lost. > Does anyone know how to preserve the colors used by the motif window > manager within my 256 element colormap? Basically, I would like to > create a (256 - N) element colormap. Where N would be the number of > colors needed to preserve the 3D-look, menus, etc. used by the mwm. One possibility is to figure out just which colormap cells mwm uses and then wire the knowledge of those cells into your program. This is ugly and nonportable (definitely not portable to other window managers, likely not portable to mwm on another server, possibly not even portable to other runs of mwm on the same server). The only other possibility that comes to mind is to find out which cells are taken in the default colormap and copy them. Herewith a brief description of how you might go about this. First, grab the server so as to avoid skew problems. Now use XAllocColors to allocate the rest of the default colormap. Remember which color values you managed to allocate; they're the ones you can use. (You may find that too few colors are available; other programs may have allocated out of the default map. In this case, I don't know what to do; you could refuse to run or perhaps ignore the existing allocations and go technicolor.) Create your own colormap. Copy the colors for all the pixels you *couldn't* allocate from the default map to your map. You can now ungrab the server. If you want to be really nice to other programs, repeat the above procedure periodically and adjust the cells you're using when necessary. der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu