Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!uunet!resq!Uucp From: Uucp@resq.fidonet.org (Uucp) Newsgroups: comp.windows.x.motif Subject: Colormaps Message-ID: <45.27F09971@resq.fidonet.org> Date: 26 Mar 91 17:59:44 GMT Organization: RES-Q, Paterson NJ (201) 881-7421 Lines: 62 From uunet!osf.org!motif-talk-request From: uunet!osf.org!dbrooks To: motif@alfalfa.com, motif-talk@osf.org Date: Tue, 26 Mar 91 09:19:41 -0500 Kee wrote: >2. Given a widget that needs an it's own colormap, what do I do to notify the > windowmanager? Asente and Swick say to use XtSetWMColormapWindows after > the widget is realized. The Xt Ref manual doesn't mention the call, and > using it doesn't seem to do anything (although I need to double check and > make sure it's realized again). Has anyone done this? Yes; the call is in section 11.10 of the Xt reference that comes with the tape. As I read it, you need to give it both a shell widget and a list of widgets who have private colormaps. I've only done it with a shell that has a private colormap inherited by all its children, not individual cmaps per widget; this code works (although it's in the process of being improved). The order of events is significant. After these calls, the wm color focus policy will install at the appropriate time. Of course, you need a decent window manager :-) ... dpy = XtDisplay(toplevel); scrn = XtScreen(toplevel); vis = DefaultVisualOfScreen(scrn); cmap = XCreateColormap(dpy, XtWindow(toplevelW), vis, AllocNone); WorkAroundVisualBug(cmap); n = 0; XtSetArg(args[n], XmNcolormap, cmap), n++; /* etc */ shell = XtCreatePopupShell("shell", topLevelShellWidgetClass, toplevelW, _ARGS(shellWargs)); /* Now you can populate the shell with its contents and manage them */ XtRealizeWidget(shell); XtSetWMColormapWindows(shell, &shell, 1); /* Cheap trick WidgetList */ XtPopup(shell, XtGrabNone); ... /* Visual.c (at least up to 1.1.3, maybe more) assumes that all colormaps * have the standard two pixels initialized the same as root, and uses these * pixel values for default foreground and sometimes background. Here we * try to meet that expectation. Unfortunately, we have to assume that * XAllocColor will allocate the entries in order 0, 1. */ static void WorkAroundVisualBug(cmap) Colormap cmap; { XColor colors[2]; Colormap default_cmap = DefaultColormapOfScreen(scrn); colors[0].pixel = 0; colors[1].pixel = 1; XQueryColors(dpy, default_cmap, colors, 2); XAllocColor(dpy, cmap, &colors[0]); XAllocColor(dpy, cmap, &colors[1]); } -- Uucp - via FidoNet node 1:269/133 UUCP: uunet!resq!Uucp