Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!bloom-beacon!EXPO.LCS.MIT.EDU!converse From: converse@EXPO.LCS.MIT.EDU (Donna Converse) Newsgroups: comp.windows.x Subject: Re: Xaw and colormap Message-ID: <9002062148.AA25304@expo.lcs.mit.edu> Date: 6 Feb 90 21:48:36 GMT References: <9002031629.AA24500@maxine.wpi.edu> Sender: daemon@athena.mit.edu (Mr Background) Organization: X Consortium, MIT Laboratory for Computer Science Lines: 70 > 1. when I click on the quit command button, the program exits but it does not > put me back to where I started off. It leaves the screen pitch black and I > have to rlogin from other w/s to kill :0. A similar program I wrote using > only Xlib functions will exit properly. I could not figure out why. Both > programs will be attached at the end. The problems discussed here are extremely common. In ximg1.c, in the function create_colormap, you write: > Window win = RootWindowOfScreen(XtScreen(w)); ... > > /* why would this not work? Why do I have use RootWindowOfScreen() > win = XtWindow(w); > */ > cmap = XCreateColormap(dpy,win,DefaultVisual(dpy,screen), AllocAll); > XSetWindowColormap(dpy, win, cmap); It does not work because the widget has no window associated with it. Read section 2.5 "Realizing Widgets" of the Xt documentation. A widget's window is created at the time that the widget is realized, not at the time that the widget is created. References to the widget's window prior to realization will return a window ID of 0 (zero), which can be taken to mean that there is no window; using this window ID in Xlib calls can result in protocol errors. Rearrange the calls in your main routine. The call to XSetWindowColormap is setting the colormap of the root window (due to your work-around of the previous bug). When you quit your application, the colormap you created becomes undefined; it is no longer a valid X resource. But nothing has communicated to the window manager that the colormap of the root window is no longer valid, therefore your entire screen is displaying undefined colors. Set the colormap on your application's windows, not the root window. After you create, assign, and define the colormap, you write: > /* on DEC3100 this call does not do anything. > XInstallColormap(dpy,cmap); > */ During the development of R4, conventions for communication between clients and window managers were designed and documented. The conventions are necessary because clients must share X resources such as colormaps. Window managers arbitrate the requests to share resources from the clients. The document is available in the core source tree in doc/ICCCM. In section 6.4, "Colormaps", the convention is given that clients must not install or uninstall colormaps. Window managers which are compliant with the conventions in the above document are free to notice a colormap change which they did not request, and are free to immediately undo the effects of that request by re-installing the previously installed colormap. It is probably the window manager on the DEC3100 which is thwarting your call to install the colormap; that window manager is behaving correctly. According to the inter-client communication conventions manual (ICCCM), your application should inform the window manager of it's preference for colormap and rely on the window manger to install the colormap. If you are not using any window manager, or if the window manager is older (written before the conventions), it may not install the colormap for you; in that case, the recommendation is to convert to a correct window manager. Section 4.1.8 of the ICCCM discusses the communication between clients and window managers concerning colormaps; it is enough for you to call XSetWindowColormap (from what little I know of your application). Donna Converse converse@expo.lcs.mit.edu