🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.x
Article #37638

Help with WM_COLORMAP_WINDOWS

#37638
From: John Polstra
Date: Thu, 01 Mar 1990 22:39
45 lines
2641 bytes
I am trying to use one of the Standard Colormaps (to be concrete, let's say
RGB_GREEN_MAP) in a window, but I can't seem to get twm to switch to the
proper colormap when the cursor enters the window.  Can somebody help me?

This is with a Sun 3/180, SunOS 4.0.1, X11R4, twm window manager, no
patches installed.  Here's what my program does:

1.  Creates a top-level application shell ("toplevel") with XtAppInitialize().
2.  Creates a widget ("canvas") with XtVaCreateManagedWidget().  This is
    a widget that I built myself, but it is very similar to the "window"
    widget example in chapter 7 of the Athena Widget Set documentation.
    I.e., it is a plain window that can be drawn into, and it provides
    callbacks for expose and resize events.
3.  Registers callbacks using XtAddCallback().
4.  Calls XtRealizeWidget(toplevel).
5.  Calls XGetStandardColormap(..., &sc, ...) to get the XStandardColormap info.
6.  Calls XSetWindowColormap(dpy, XtWindow(canvas), sc.colormap).
7.  Calls XtSetWMColormapWindows(toplevel, &canvas, 1).
8.  Calls XtAppMainLoop().

When I first start up the X server, I run "xstdcmap -all" to create all of
the standard colormaps.

When I run my program, my expose callback gets called.  It draws its
image, which looks OK except that the colors are all wrong.

A call to XGetWindowAttributes() within the expose callback confirms
that the window colormap is the correct one for RGB_GREEN_MAP.  The
visual ID looks OK too (PseudoColor).  Using XQueryColors() shows that
the RGB values in the colormap are appropriate for RGB_GREEN_MAP.

If I use xprop to print out the window properties, it says
"WM_COLORMAP_WINDOWS(WINDOW): window id #  0x800002", and that is indeed
the correct window ID for my canvas widget.

I have found that I can get the desired behavior by replacing step 6 with an
XSetWindowColormap on my toplevel window, and eliminating step 7 entirely.
But I don't really *want* my toplevel window to use the RGB_GREEN_MAP.

Am I doing something wrong, or have I found a bug?
-- 

-  John Polstra               jdp@polstra.UUCP
   Polstra & Co., Inc.        ...{uunet,sun,pyramid}!practic!polstra!jdp
   Seattle, WA                (206) 932-6482
Technical Details
Message-ID: <2909@polstra.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!mips!prls!pyramid!leadsv!practic!polstra!jdp

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!mips!prls!pyramid!leadsv!practic!polstra!jdp
From: jdp@polstra.UUCP (John Polstra)
Newsgroups: comp.windows.x
Subject: Help with WM_COLORMAP_WINDOWS
Message-ID: <2909@polstra.UUCP>
Date: 1 Mar 90 22:39:54 GMT
Reply-To: jdp@polstra.UUCP (John Polstra)
Organization: Polstra & Co., Seattle
Lines: 45