shamash@cs.columbia.edu (Ari Shamash) (08/28/89)
Can somebody please help me with allocating a standard color map? From what I gathered by reading The XLib manual, the following program should work.. I'm using X11 R.3, TWM, and SunOS 4.0 on a Sun 3/60. I've tried this with UWM, too, to no avail. Here is my program: #include <stdio.h> #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/Xatom.h> main (argc, argv) int argc; char **argv; { Display *display; int screen; Window window; unsigned long foreground; XSizeHints hint; XStandardColormap mystd; GC gc; display = XOpenDisplay(""); screen = DefaultScreen(display); hint.x = 200; hint.y = 300; hint.width = 300; hint.height = 300; hint.flags = PPosition | PSize; window = XCreateSimpleWindow(display, DefaultRootWindow(display), hint.x, hint.y, hint.width, hint.height, 5, WhitePixel(display, screen), BlackPixel(display, screen) ); XSelectInput(display, window, ExposureMask); gc = XCreateGC (display, window, 0, 0); XSetBackground(display, gc, WhitePixel(display, screen)); XSetForeground(display, gc, BlackPixel(display, screen)); XMapRaised(display, window); XFlush(display); if (XGetStandardColormap(display, RootWindow(display, DefaultScreen(display)), &mystd, XA_RGB_DEFAULT_MAP) == 0) { printf("XGetStandardColormap failed.\n"); } XFreeGC(display, gc); XDestroyWindow(display, window); XCloseDisplay(display); exit(0); } Thanks in advance, Ari -- shamash@cs.columbia.edu shamash@gollum.cs.columbia.edu ...!rutgers!columbia!shamash
rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (08/29/89)
Can somebody please help me with allocating a standard color map? There aren't any clients in R3 that create standard colormaps, so your attempt to read one from the server will fail. There will be support in R4.
phil@BRL.MIL (Phil Dykstra) (08/29/89)
There aren't any clients in R3 that create standard colormaps, so your attempt to read one from the server will fail. Yet every R3 based server that I've layed hands on has returned "Success" to XGetStandardColormap() while the XStandardColormap struct info is all zero. A bug isn't it? As a workaround I test for a non zero colormap field in the struct.... The creation of Standard Colormaps is documented as the job of the window manager (or other clients if they don't exist). It seems to me though that these are pretty closely tied to the server specifics and the Visuals that it supports. Wouldn't it make sense for the server to create some of these? - Phil
rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (08/29/89)
Yet every R3 based server that I've layed hands on has returned "Success"
to XGetStandardColormap() while the XStandardColormap struct info is all
zero.
Haven't the time now to see if there's an R3 bug. The following fails
correctly in our development system:
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
main()
{
Display *dpy;
XStandardColormap cmap;
dpy = XOpenDisplay(0);
if (!XGetStandardColormap(dpy, DefaultRootWindow(dpy), &cmap, XA_RGB_BEST_MAP))
printf("failed\n");
XCloseDisplay(dpy);
exit(0);
}
It seems to me though that these are pretty closely tied to the server
specifics and the Visuals that it supports. Wouldn't it make sense for
the server to create some of these?
I don't think so.
phil@BRL.MIL (Phil Dykstra) (08/29/89)
Bob, et.al., Sorry for the false alarm. XGetStandardColormap does work correctly in R3. It was my dumb mistake. - Phil