Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!wugate!uunet!brunix!doorknob!mnp From: mnp@cs.brown.edu (Matthew Nicholas Pappas) Newsgroups: comp.windows.x Subject: Re: Setting up color tables for an image. Message-ID: Date: 19 Oct 89 17:48:20 GMT References: : <4743@ncar.ucar.edu> Sender: news@brunix.UUCP Organization: Brown University Department of Computer Science Lines: 72 In-reply-to: davis@karl.ucar.edu's message of 17 Oct 89 20:36:16 GMT In article <4743@ncar.ucar.edu> davis@karl.ucar.edu (Glenn P. Davis) writes: From: davis@karl.ucar.edu (Glenn P. Davis) Newsgroups: comp.windows.x Keywords: XInstallColormap Date: 17 Oct 89 20:36:16 GMT Reply-To: davis@karl.UCAR.EDU (Glenn P. Davis) Organization: Unidata/UCAR, Boulder CO I'm experimenting with a very simple X client to render color images. ... What is the correct sequence of calls to create and install the new colormap? ... cmap = XCreateColormap(dpy, XtWindow(box3), vis, AllocAll) ; ok XStoreColors(dpy, cmap, colors, ncolors) ; ok XInstallColormap(dpy,cmap); NOT ok. Read the manpage for this function. Only window managers should call this function. Or look at the Gettys & Scheifler book (you know--the maroon one). I have also fooled around with not executing 'XInstallColormap' in the main line code, instead adding two event handler to 'box' for entering and leaving the box, Install and UnInstall the colormap. You're still not allowed to call XInstallColormap (even if the mouse entered your window). This latter system works when I'm not running any window manager. You are in effect acting as the window manager. It doesn't with twm, even with ncolors = 64. I assume I'm not being 'a good client'. This is true. But it's hard to know that without trying first. What should I be doing? Assuming your toplevel widget has the same visual type as the root window (which it must if you are using release 3), call XSetWindowColormap after you call XStoreColors in the code above. XSetWindowColormap sets a property on your toplevel window; this property is read by the window manager, and the window manager then makes sure that your colormap is installed (using XInstallColormap) whenever your window has the colormap focus. Note that the mous probably has to be inside your window for the window manager to give you the colormap focus. If you are using a nonstandard visual, or just want a better sense of the more complex issues of colormap sharing/installation, read the ICCCM doc, which is available on expo (18.30.0.212). It's actually one of the shorter X documents, and reasonably readable. For the case ncolors = 64, I would prefer to set things up so there is no 'flash', if possible. There shouldn't be any serious flash. Be more specific if you think this is a problem. Thanks Glenn P. Davis UCAR / Unidata PO Box 3000 1685 38th St. Boulder, CO 80307-3000 Boulder, CO 80301 (303) 497 8643 Good luck, -matt Brown Graphics Group _________________________________________________________________________ uunet ! brunix ! mnp Matthew Nicholas Pappas or mnp @ {cs.brown.edu, browncs.bitnet } Brown University