Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!samsung!uakari.primate.wisc.edu!uflorida!bikini!thoth From: thoth@reef.cis.ufl.edu (Gilligan) Newsgroups: comp.windows.x Subject: Re: Need 8/24 bit colormap help Message-ID: Date: 9 Sep 90 20:15:59 GMT Sender: news@uflorida.cis.ufl.EDU Distribution: comp Organization: Zik Zak Lines: 46 Funny, I think I just solved this problem yesterday. I doubt it is your XSetWindowColormap call failing. It's probably the XCreateWindow call. If you create the window WITHOUT SETTING the colormap field of the XSetWindowAttributes structure the window will be created with its parent's colormap which is a BadMatch (colormap from different visual). A subsequent attempt to set the colormap will fail because the X server is already pissed off and there is no such window. The code on page 210 in Book 1 (purple or cyan) is BOGUS. Here's my code fragment that works on our R4 Sun 3/80s and 3/60s. It won't do exactly what you want but I think it's a good example of how to create window's under bizzarre visuals. xvi.class = StaticGray; vlist = XGetVisualInfo(dpy, (long)VisualClassMask, &xvi, &number); if (!number) { printf("No visuals. gbye\n"); exit(1); } screen = vlist->screen; rwin = RootWindow(dpy,screen); cmap = XCreateColormap(dpy, rwin, vlist->visual, AllocNone); xswa.colormap = cmap; win = XCreateWindow(dpy, rwin, 0, 0, width, height, 1, vlist->depth, InputOutput, vlist->visual, (long)CWColormap, &xswa); #if 0 /* this doesn't work because the creation of the window fails. You must create the window with the colormap set in the XSetWindowAttributes structure or it will BadMatch trying to use its parent's. */ XSetWindowColormap(dpy, win, cmap); #endif -- #perl -ne #/-------------------- print "a window is a terrible thing to paste -", $me; #( My name's not really Gilligan, It's Robert Forsman, without an `e' ) s/Gilligan/Robert Foresman/g; s/Foresman/Forsman/g; #--------------------/