Newsgroups: comp.windows.x
Path: cantaloupe.srv.cs.cmu.edu!crabapple.srv.cs.cmu.edu!bb3.andrew.cmu.edu!news.sei.cmu.edu!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!unixhub!headwall.Stanford.EDU!nntp.Stanford.EDU!leland.Stanford.EDU!leec
From: leec@cb-iris.Stanford.EDU (Christopher Lee)
Subject: HELP! Setting Colormaps on multi-top-level APP
Message-ID: <1993Apr20.214517.13057@leland.Stanford.EDU>
Keywords: GLX mixed-model,colormap
Sender: news@leland.Stanford.EDU (Mr News)
Organization: DSG, Stanford University, CA 94305, USA
Date: Tue, 20 Apr 93 21:45:17 GMT
Lines: 71


Dear SGI and netter GL-X Mixed-Model experts,
I am writing a mixed model application that creates a couple different
color maps for different windows, and I've been having trouble getting
the window manager to reliably honor my requests.  In some environments
(entry level R3000 Indigo w/ 4.0.5) all windows are getting properly
connected to their designated color maps, but on others (an IRIS 4D 240/GTX;
also a different entry level Indigo) the color mapping is unreliable
and changes behavior when I compile at different times.  The most common
problem is that all non-top-level windows fail to be displayed according
to their colormap.  My application starts out by creating three top-level
windows; in some cases all but the first of these also fail to be
displayed by their colormap.  This is spectacularly aggravating.

I would dearly appreciate
  1. an explanation of the standard, RIGHT, CORRECT way to give a window
  a colormap such that the Window Manager will Honor and Obey it;

  2. any advice about problems that could cause my failure to get my
  desired colormaps.

By now I have exhausted my own attempts on this, having tried everything
reasonable or imaginable.

Below is example code giving the schematic for how I have been *TRYING*
to do this.  Please, please, please SOMEBODY tell me what I am doing
wrong/how to do it right!!!


Yours,

Chris Lee

/***********************************************************************/
Display* dpy;  /* DECLARE SOME DATA... */
Colormap popup_cmap;
XColor mycolor;
Window win;
XSetWindowAttributes cwa;
int nwlist;
Window *wlist;

/* NB: FOR BREVITY, NOT SHOWING ALL CODE LINES--JUST A SCHEMATIC */

popup_cmap=XCreateColormap(dpy,DefaultRootWindow(dpy),vis->visual,AllocAll);

/* HERE WE STORE A BUNCH OF COLORS USING
   XStoreColor(dpy,popup_cmap,&mycolor); ... */

cwa.colormap = popup_cmap;
win = XCreateWindow(dpy, parent, x, y, w, h,
                    borderWidth, vis->depth, InputOutput, vis->visual,
                    CWColormap|CWBorderPixel, &cwa);


/* LIST ALL SUB WINDOWS OF my_topwin, PARENT OF win, INTO wlist;
   nwlist IS COUNTER OF ENTRIES IN wlist.

   NB: wlist is static storage that can be relied on not to go away
       or be corrupted.  I thought of that!  Does anyone know if
       setting WM properties is by data copy, or by reference pointer?

       ie. is it acceptable to pass data for a Property, then free
       the data?   */
XSetWMColormapWindows(dpy,my_topwin,wlist,nwlist);

XMapRaised(Display0,win);

/* LATER ON WE HANDLE XEvents NORMALLY... TYPICAL EVENTLOOP */


