[comp.windows.x] Background color of a window

jlf@earth.CRAY.COM (John Freeman) (11/01/88)

I want to find the background pixel value of an existing window,
one I did not create.  The XSetWindowAttributes structure has
a field for background_pixel, but XGetWindowAttributes returns
an XWindowAttributes structure which does not have this field.
In other words, I want the equivalent of XGetBackground (and
XGetForeground), the counterparts of XSetBackground and
XSetForeground, which do exist.

jim@athsys.uucp (Jim Becker) (11/02/88)

From article <8810311945.AA24289@thelake.cray.com>, by jlf@earth.CRAY.COM (John Freeman):
> I want to find the background pixel value of an existing window,
> one I did not create.  The XSetWindowAttributes structure has
> a field for background_pixel, but XGetWindowAttributes returns
> an XWindowAttributes structure which does not have this field.


	As long as this has been mentioned... There are a number of 
settable window attributes that cannot be retrieved from the window
using the XGetWindowAttributes. Sometimes there is a need for these
esoteric items to be gotten (such as trying to match the backing
pixmap of the root window..). This is Frustrating!!


	Is there any effort, or chance (at this late stage in the game),
to make the XSetWindowAttributes and the XWindowAttributes the same??
I know that this is impossible, as are (m)any changes, but what was the
motivation that went into this decision?


-Jim Becker

rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (11/03/88)

	Is there any effort, or chance (at this late stage in the game),
    to make the XSetWindowAttributes and the XWindowAttributes the same??

There is no effort within the X Consortium at this time to make such a
change.  My recollection is that this is one of many changes that someone
has proposed to talk about at the X Conference in January.

    I know that this is impossible, as are (m)any changes, but what was the
    motivation that went into this decision?

One more time (with less and less feeling).  The reason is similar to why
components of GCs cannot be read back either.  Things that get stored into
the window (or GC) as resource ids can typically be "freed" (that is, the
association deleted between the resource id and the "object") without
affecting what's in the window (or GC).  If you then wanted to ask for
the value back, the server wouldn't have a resource id to give you.  For
the case of background pixmap and cursor, it was assumed that you would
commonly free the resource right after storing it, to minimize memory
consumption in the server (since the server might have made a copy of
the object at the point you stored the attribute).  Rather than having
GetWindowAttributes have some way of saying "I don't know", the
information simply wasn't made readable from the protocol.  Perhaps a
bad decision (given the continual questions about it), but that was the
rationale.