[comp.windows.x.motif] Gadget background color bug?

ctim@aaet.csc.ti.com (Craig Timmerman) (05/18/91)

I am posting this for a friend who does not have newsgroup access.
Please followup to this newsgroup or respond to the email address
below.  Thanks.


I have observed a strange interaction when changing background colors of a
family of XmForm widgets with XmPushButtonGaget children.  I would appreaciate
any light anyone can shed on this.


I have a XmForm widget that contains several XmPushButtonGaget children.  They
are defined in a Motif .uil file.  My application creates several instances of
the XmForm Widget by calling MrmFetchWidget.

>From time to time to show program status information, I change the background
color of a specific XmForm widget instance by doing XtSetValues on its
XmNbackground.  The background color of the XmForm widget and all its
XmPushButtonGaget children changes as expected.

What is not expected is the side effect on the background color of the
XmPushButtonGaget children of the other XmForm widget instances when they are
subsequently redrawn, as in an exposure event.  This is a typical scenario:

    * Create XmForm widget instances: FW1, FW2, FW3
    * Manage them and they are rendered correctly (each XmForm widget and 
	their XmPushButtonGaget children have the same background color)
    * They handle exposure events and are rendered correctly.

    * XtSetValues the XmNbackground of one XmForm widget (eg: FW2)
    * FW2 and its XmPushButtonGaget children are redrawn with the correct
	new background color.

    * On the next exposure event:
      - FW2 and its XmPushButtonGaget children are still rendered
	  correctly, with their new background color
      - FW1 & FW3 are redrawn correctly, BUT ...
	    THEIR XmPushButtonGaget CHILDREN ARE REDRAWN WITH
     	    THE NEW BACKGROUND COLOR JUST GIVEN TO FW2!

I know that gadgets don't have their own background color value; they inherit
it from their widget parent.  Some looking at the Private .h files tells
me that XmPushButtonGaget objects have a "background_gc" value.  I would
assume that the widget parent creates this GC, to be shared by its gadget
children.  My suspicion is that this is done with XtGetGC, to share GCs,
rather than with XCreateGC.  Further, I suspect that this shared GC is shared
not just by the gadget children of one widget, but by the gadget children of
all instances of of a similar widget parent.  My final assumption is that when
the widget parent process the XmNbackground XtSetValues that it modifies this
GC (rather than creating a new one) so its children will have the correct
color.  If multiple widgets' child gadgets indeed share a GC ... surprise!

I haven't read enough code to confirm this theory, but it would explain the
side effect that I'm seeing.  I'd like to know:

  ? Can anyone confirm if this theory is correct (or offer another)?
  ? Has anyone else seen the same problem?  
  ? Is this a known, reported X (Motif?) bug?
  ? Should it be?   (Or, is it somehow a "feature"?)

Thanks for any help.

----------------------------------------------------------------------
Henry Burks		burks@wrek.csc.ti.com
Texas Instruments 
Dallas, Tx              Phone: (214)575-3192
----------------------------------------------------------------------