[comp.windows.x] Is a transparent background possible?

jwdb@dutnak2.tudelft.nl (Jan Willem de Bruijn) (08/30/90)

Has anyone ever managed to create transparent windows (or widgets)
using the Xtoolkit?  It says in the Intrinsics Programming Manual
that the background attribute of a window can be transparent, but
nowhere is it explained how to accomplish that.
Say, e.g., that I wanted to have a transparent background for the
Command widget in the xgoodbye application from Chapter 2 (as you
can tell from this, I am just learning to program using the toolkit),
how would I go about it?  The obvious way, to put:

*goodbye.background: transparent

in the application-defaults file (or in ~/.Xdefaults) is not accepted
by the toolkit.  (It results in the warning "Cannot allocate colormap
entry for "transparent"".)
Surely, transparent windows could be useful; but, come to think of
it, I have never seen one on the X window system, unless the ghost
window that appears when you move a window using the window manager
is actually a transparent window.
--
JanWillem de Bruijn            ...!uunet!mcsun!hp4nl!dutrun!dutnak2!jwdb
Seismics and Acoustics                           jwdb@dutnak2.tudelft.nl
Faculty of Applied Physics         Discipline is never an end in itself,
Delft University of Technology         only a means to an end.

pothiers%pi3.local%netvax@CCC.NERSC.GOV (Steve Pothier) (08/31/90)

   Has anyone ever managed to create transparent windows (or widgets)
   using the Xtoolkit?  It says in the Intrinsics Programming Manual
   that the background attribute of a window can be transparent, but
   nowhere is it explained how to accomplish that.

Well, sort of. I've set the background to none (NULL?). When the
widget came up whatever was behind the widget appeared in place of the
background. I said "Oh, great. Its transparent" then moved the window.
The background remained the same (i.e. it didn't get update to reflect
the new obscured display.). I was using MWM and my own widget.



==============================================================================
Steve Pothier
pothiers%tuva.sainet@ccc.nersc.arpa
Science Applications International
Tucson, AZ
602-748-7400
==============================================================================

adri@dutncp8.tudelft.nl (A.B. van Woerkom) (09/03/90)

jwdb@dutnak2.tudelft.nl (Jan Willem de Bruijn) writes:

>Has anyone ever managed to create transparent windows (or widgets)
>using the Xtoolkit?  It says in the Intrinsics Programming Manual
>that the background attribute of a window can be transparent, but
>nowhere is it explained how to accomplish that.

When you set the background_pixmap field in the window attibutes to None
the background of the window will be set equal to whatever it is behind your
window when it is mapped, thus creating a transparent effect.
However when the things behind your window change your window's background
won't change with it.  Also when your move your window the initial background
will move with it.

>Say, e.g., that I wanted to have a transparent background for the
>Command widget in the xgoodbye application from Chapter 2 (as you
>can tell from this, I am just learning to program using the toolkit),
>how would I go about it?  The obvious way, to put:
>
>*goodbye.background: transparent
>
>in the application-defaults file (or in ~/.Xdefaults) is not accepted
>by the toolkit.

You have to set *goobye.backgroundPixmap (to None) instead.
This only can be done, however, from your program (XtSetArg and all that)
because there is no string to pixmap converter (but you can allways write and
register one yourself :-)).

To get a really tranparent window, but one on which you can't draw, set the
window type to InputOnly on creation, but how to archieve this from Xt I don't
know.
________________________________________________________________________
Adri van Woerkom, adri@dutncp6.tudelft.nl
Delft University of Technology, Faculty of Applied Physics, Department
Physics Informatics, section Computational Physics, Lorentzweg 1,
2628 CJ  DELFT, The Netherlands
________________________________________________________________________
"Do you want the usual answer or the truth?" (Igor Strawinsky)