[comp.windows.x] Transparent windows

edjames@ic.Berkeley.EDU.UUCP (02/02/87)

Does anyone know what the status of transparent windows is in V11?

The document says they are to be removed, and the "replacements",
opaque windows without backgrounds, do not seem to be able to do
everything that transparent windows do, namely clipping.

I heard a rumor that they were to be left in V11 due to complaints
from the world.  Anybody have the scoop on this?
								--ed

jg@jumbo.UUCP (02/02/87)

In article <1262@ucbcad.berkeley.edu> edjames@ic.berkeley.edu (Ed James) writes:
>Does anyone know what the status of transparent windows is in V11?
>
>The document says they are to be removed, and the "replacements",
>opaque windows without backgrounds, do not seem to be able to do
>everything that transparent windows do, namely clipping.
>
>I heard a rumor that they were to be left in V11 due to complaints
>from the world.  Anybody have the scoop on this?
>								--ed

The reality is that the function of transparent windows is being split;
the clipping function of transparent windows is much better dealt with
using the full region support in V11; the input discrimination and cursor
control by InputOnly windows.  The overloaded semantics of transparent
windows were far from ideal.  We were unable to find any examples of
an application which used both semantic cases at the same time; they were
either being used as poor man's regions or as cursor control/input
functions.
					Jim

black@masscomp.UUCP (02/03/87)

In article <1262@ucbcad.berkeley.edu> edjames@ic.berkeley.edu (Ed James) writes:
>Does anyone know what the status of transparent windows is in V11?
>
>I heard a rumor that they were to be left in V11 due to complaints
>from the world.  Anybody have the scoop on this?

I believe the current plan is to have two classes of windows, called

	InputOutput, and
	InputOnly

InputOnly windows serve the same purpose as X10 transparent windows,
although I believe they aren't used for clipping.  To do the clipping
operations, you can specify a graphics context that has a list of
clipping rectangles where your transparent window would have been.

	- sam black

----------------------------------------------

There are only two kinds of planes in the world:
Fighters and targets.
			- 1Lt. Steven Brown, 63 TFTS

	...!{decvax,allegra,harvard,seismo,ihnp4}!masscomp!black

----------------------------------------------

keith@EXPO.LCS.MIT.EDU (Keith Packard) (09/14/89)

> I am writing an application that requires "transparent" windows.
> I am hoping to achieve this by mapping multiple screens to the same
> display surface.

This is certainly not the model I would suggest for providing transparent
windows.  A better design is to create a new visual type (transparent
static gray or whatever you have), create a trivial extension which returns
the visualid of this new visual type, and the magic pixel value which
makes it transparent, and then create windows using the new visual type.
Automatically, you get cursor positions relative to both windows, you only
get one cursor and everything else works out fine (Enter and Leave
events work as expected).

Very small server changes will yield the desired results.  I suspect some
minor changes in ValidateTree will be required to get the correct
exposure events sent to the windows.

Please keep the mistakes of the past (the multiple screen hack for the
Sun 3/60 CG4 display) from clouding your judgement about how transparent
overlays should work.

Keith Packard
MIT X Consortium

dhuff@AMD-26.HAC.COM (Daryl Huff) (09/14/89)

I am writing an application that requires "transparent" windows.
I am hoping to achieve this by mapping multiple screens to the same
display surface.  Map data will be put into one screen and another screen
can be used for things like pull-down menus.  Now, assuming the LUT is
programmed correctly, a pull down menu does not obscure the map.  (I realize
that this mix may result in a jumbled mess is the LUT is not programmed
correctly.)  

My problem is in the event generation for the two screens.  I want events 
such as expose events to be reported on a per screen basis, but I want events
such as the pointing devices motion to be reported as if there was a cursor
in both screens.  For example, take two windows the first window, A, in screen 1 and  the second window, B, in screen 2.   Now, assume that window A is
adjacent to window B on the display surface.  As the cursor is moved 
across the display surface I want the EnterNotify, LeaveNotify, etc. events
to be generated for both windows even though they are in different screens.

Is this possible?  If so could you give me an idea of how to do it and if not
is there anything I can do to the server to make this work?

dhuff@AMD-26.HAC.COM (Daryl Huff) (09/14/89)

> windows.  A better design is to create a new visual type (transparent
> static gray or whatever you have), create a trivial extension which returns
> the visualid of this new visual type, and the magic pixel value which
> makes it transparent, and then create windows using the new visual type.

I don't understand what you mean by "magic pixel value".  Let me explain
a bit more about what I hope to accomplish.  The system I am working on has
an 8 plane frame buffer.  I would like to be able to split the planes into
two or three groups.  For example I may want to split the 8 planes into two
groups of four planes each.  The first group of four planes would be used
to display windows with maps in them.  The second group of four planes could
 be used for menues, xterm windows, etc.  I want the map data to be 
visible "through" the menues, xterm windows, etc.  I want the cursor to give
positions relative to any window (map or xterm).  I also want separate
expose events for the two groups of planes.  (i.e. The map windows should
generate exposure events when a pop-up menu is brought up then taken away.)

cinzia@pisa.intecs.it (Cinzia bonini) (07/19/90)

I'm doing GUI development using X11R3, the Xt Intrinsics
and the AT&T OpenLook Toolkit.
I run the AT&T OpenLook window manager (olwm).

I want to define a new widget class (TransClass) which is a subclass of
the predefined "core" class with the constraint that each widget belonging
to this class is constituted by a transparent window with no border.
The class record I have defined is the following:

TransClassRec transClassRec = {
  {
/*--------------------   core_class fields   ---------------------*/
    /* superclass               */      (WidgetClass) &widgetClassRec,
    /* class_name               */      "Trans",
    /* widget_size              */      sizeof(TransRec),
    /* class_initialize         */      ClassInitialize,
    /* class_part_initialize    */      NULL,
    /* class_inited             */      FALSE,
    /* initialize               */      Initialize,
    /* initialize_hook          */      NULL,
    /* realize                  */      Realize,
    /* actions                  */      actions,
    /* num_actions              */      XtNumber(actions),
    /* resources                */      resources,
    /* num_resources            */      XtNumber(resources),
    /* xrm_class                */      NULLQUARK,
    /* compress_motion          */      FALSE,
    /* compress_exposure        */      TRUE,
    /* compress_enterleave      */      FALSE,
    /* visible_interest         */      FALSE,
    /* destroy                  */      Destroy,
    /* resize                   */      XtInheritResize,
    /* expose                   */      Redisplay,
    /* set_values               */      NULL,
    /* set_values_hook          */      NULL,
    /* set_values_almost        */      XtInheritSetValuesAlmost,
    /* get_values_hook          */      NULL,
    /* accept_focus             */      NULL,
    /* version                  */      XtVersion,
    /* callback_private         */      NULL,
    /* tm_table                 */      defaultTranslations,
    /* query_geometry           */      XtInheritQueryGeometry,
    /* display_accelerator      */      XtInheritDisplayAccelerator,
    /* extension                */      NULL
  },
/*-----------------------   Trans class fields   ------------------*/
  {
    /* dummy                    */	0
  }
};

In turn every widget of class TransClass will be child of a widget
belonging to another widget class (FullClass) wich is a subclass of the
predefined "composite" class.
The class record I have defined is the following:

FullClassRec fullClassRec = {
  {
/*-------------------   core_class fields   -----------------------*/
    /* superclass         */    (WidgetClass) &compositeClassRec,
    /* class_name         */    "Full",
    /* widget_size        */    sizeof(FullRec),
    /* class_initialize   */    ClassInitialize,
    /* class_part_init    */    NULL,
    /* class_inited       */    FALSE,
    /* initialize         */    Initialize,
    /* initialize_hook    */    NULL,
    /* realize            */    Realize,
    /* actions            */    actions,
    /* num_actions        */    XtNumber(actions),
    /* resources          */    resources,
    /* num_resources      */    XtNumber(resources),
    /* xrm_class          */    NULLQUARK,
    /* compress_motion    */    TRUE,
    /* compress_exposure  */    TRUE,
    /* compress_enterleave*/    TRUE,
    /* visible_interest   */    FALSE,
    /* destroy            */    Destroy,
    /* resize             */    NULL,
    /* expose             */    Redisplay,
    /* set_values         */    SetValues,
    /* set_values_hook    */    NULL,
    /* set_values_almost  */    XtInheritSetValuesAlmost,
    /* get_values_hook    */    NULL,
    /* accept_focus       */    NULL,
    /* version            */    XtVersion,
    /* callback_private   */    NULL,
    /* tm_table           */    defaultTranslations,
    /* query_geometry     */    NULL,
    /* display_accelerator*/    XtInheritDisplayAccelerator,
    /* extension          */    NULL
  },{
/*-------------------  composite_class fields -------------------- */
    /* geometry_manager   */    XtInheritGeometryManager,
    /* change_managed     */    XtInheritChangeManaged,
    /* insert_child       */    XtInheritInsertChild,
    /* delete_child       */    XtInheritDeleteChild,
    /* extension          */    NULL
  },
/*--------------------   Full class fields   -----------------------*/
  {
    /* dummy	          */	0
  }
};

The goal should be that when two or more widgets of TransClass overlap,
graphics objects inside them should be drawn as their windows were transparent
that is graphic objects of both windows should be displayed.

To achieve this behaviour I have tried the following (widget resources,
actions and operations such as Redisplay, Destroy etc. have been defined
as well):

/*-----------------------------------------------------------------*/
void main(argc, argv)
     int	argc;
     char	*argv[];
{
  Widget	toplevel, w, pane, foot;
  FullWidget	full;
  TranWidget	trans;
  int		argnr;
  Arg		args[10];

  toplevel = OlInitialize( "TEST", "test", NULL, 0, &argc, argv);

  dpy = XtDisplay(toplevel);

  w = XtAppCreateShell("myAppl", "appl_class", baseWindowShellWidgetClass, dpy, NULL, 0);

  argnr = 0;
  XtSetArg(args[argnr],XtNx, (XtArgVal) 0); argnr++;
  XtSetArg(args[argnr],XtNy, (XtArgVal) 0); argnr++;
  XtSetArg(args[argnr],XtNwidth, (XtArgVal) 400); argnr++;
  XtSetArg(args[argnr],XtNheight, (XtArgVal) 300); argnr++;
  foot = XtCreateManagedWidget("name", footerPanelWidgetClass, w, args, argnr);

  argnr = 0;
  XtSetArg(args[argnr],XtNwidth, (XtArgVal) 400); argnr++;
  XtSetArg(args[argnr],XtNheight, (XtArgVal) 300); argnr++;
  pane = XtCreateManagedWidget("pane", scrolledWindowWidgetClass, foot, args, argnr);

  argnr = 0;
  XtSetArg(args[argnr],XtNwidth, (XtArgVal) 800); argnr++;
  XtSetArg(args[argnr],XtNheight, (XtArgVal) 600); argnr++;
  full = (FullWidget)XtCreateManagedWidget("full", fullWidgetClass, pane,args, argnr);

  argnr = 0;
  XtSetArg(args[argnr],XtNborderWidth, (XtArgVal)0); argnr++;
  XtSetArg(args[argnr], XtNbackgroundPixmap, (XtArgVal)NULL);

  trans = (TransWidget)XtCreateManagedWidget("trans", transWidgetClass, full, args, argnr);

  XtRealizeWidget((Widget) w);

  doOperations(trans);

  XtMainLoop();

}
/*----------------------------------------------------------------*/

where the procedure "doOperations" performs some operations as graphic
drawings, widget moving and resizing.

What happens is that the widget is effectively created and mapped
"transparently" meaning that its background is set to whatever is under
its window so showing what is overlapped.
But when I move the widget inside the parent window the background is
not changed again to what is overlapped in the new position.

Moreover when I create two widgets of TransClass and then I move one
of them (calling XtMoveWidget) so that it overlaps the other, it
completely hides the latter and no transparency effect is achieved.

Does anyone have solutions to this or give me any suggestion ?
I would very appreciate it.

	cinzia@intecs.uucp

P.S.
May be I'm wrong but I have heard that "transparent windows" were present
in X10 and that they have been disappeared in X11/R3 since they
can be obtained with a simple workaround: is it true ?  If yes, can
somebody tell me how can I do it?

cookson@helios.mitre.org (Cookson) (07/27/90)

Does anyone know of a way to create a window with a transparent background,
so you can see what's under it, but that you can also draw in??

Thanks,
Dean


# Dean Cookson	dcookson@mitre.org	$ "It's like teaching telfon,	      #
# {devax,etc}!linus!mbunix!helios!cookson $ whatever you say to her just      #
# Disclaimer: My opinions are my own, and   $ bounces right off"  -Mike Hess  #
#	are of questionable sanity.	      $-------------------------------#

J.K.Wight@newcastle.ac.UK (Jim Wight) (07/27/90)

In article <114875@linus.mitre.org> Dean Cookson writes
> Does anyone know of a way to create a window with a transparent background,
> so you can see what's under it, but that you can also draw in??

Use InterViews. Derive from Interactor but don't fill or clear the
background within Redraw.

Jim Wight
---------
J.K.Wight@newcastle.ac.uk
Computing Laboratory, University of Newcastle upon Tyne
Newcastle upon Tyne, NE1 7RU, United Kingdom.      Tel: +44 91 222 8238

mouse@LARRY.MCRCIM.MCGILL.EDU (07/28/90)

> Does anyone know of a way to create a window with a transparent
> background, so you can see what's under it, but that you can also
> draw in??

Depending on what you want it for, one possibility is a window with a
background-pixmap of None.  However, this is probably not quite what
you want.  In particular, clearing a piece of such a window does not
erase the graphics; a background of None means that "clearing" a piece
of the window does not disturb the current contents of the window.

Another possibility, if you're using R4, is to use the SHAPE extension.
But typical implementations of SHAPE are very slow when changing
shapes, so you may not be able to do what you want this way.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu

kall@MAYO.EDU (Bruce Kall) (11/09/90)

Does anybody have a suggestion about how to make a Xlib window transparent
except
for items drawn in it with GCs in an opaque color?  I want to display a round
menu button
in a transparent window and don't want anything but the menu button (which is
not rectangular)
to be opaque.  I can't use the background color/pixmap of the window(s) behind
it because
it may be overlapping two windows or it may be on top of an image which is
grayscale.

Thanks in advance.







\------------------------------------------------------------\
 \   Bruce Kall                \  Internet:   Kall@Mayo.edu   \
  \   Mayo Clinic (Foundation)  \  Phone: (507)-255-4768       \
   \   Rochester, MN 55905       \                              \
    \------------------------------------------------------------\

mouse@LARRY.MCRCIM.MCGILL.EDU (11/10/90)

> Does anybody have a suggestion about how to make a Xlib window
> transparent except for items drawn in it with GCs in an opaque color?

You can't really.  But read on....

> I want to display a round menu button in a transparent window and
> don't want anything but the menu button (which is not rectangular) to
> be opaque.  I can't use the background color/pixmap of the window(s)
> behind it because it may be overlapping two windows or it may be on
> top of an image which is grayscale.

About the only option I see is the SHAPE extension.  You could use a
window with background None, but only if the stuff underneath the
bounding rectangle isn't going to be changing while the button is up.

For the SHAPE extension, see mit/doc/extensions/shape.ms on the MIT R4
tape....

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu

cadp16@vaxa.strath.ac.uk (03/08/91)

How would I go about creating a transparent window in X.

It has to be the full size of the screen, or rather the same size as the root
window, with no border...

Any ideas ?
 
--------------------------------------------------------------------------------
Electric Monk~~~			      		/^^^\                
					     	       > o.o <              
Strathclyde University			      		\___/           
Computer Science			      		/ V \            
3rd Year				     	       <==+==>        
Amiga and X-Windows a speciality	    	      /       \       
					  	     ^^^U^^^U^^^     
--------------------------------------------------------------------------------

cjmchale@cs.tcd.ie (Ciaran McHale) (03/09/91)

In <1991Mar8.130813.10424@vaxa.strath.ac.uk> cadp16@vaxa.strath.ac.uk writes:

>How would I go about creating a transparent window in X.
>
>It has to be the full size of the screen, or rather the same size as the root
>window, with no border...

It depends what you mean by transparent. You might mean an
InputOnly window which you cannot draw to, does not obscure
what lies underneath but can receive input (button and key
presses etc). On the other hand you might be thinking of a
window which "shows through" what's underneath but you can
also draw into. If this is the case then you can either make
use of the Shape extension or use an InputOutput window with
a background of None. In the latter case, the initial
contents of the window are whatever lays underneath but the
window's contents *won't* be updated if to reflect updates to
windows underneath.


Ciaran.
-- 
Ciaran McHale		"Verbosity says it all"			      ____
Department of Computer Science, Trinity College, Dublin 2, Ireland.   \  /
Telephone: +353-1-772941 ext 1538	FAX: +353-1-772204	       \/
Telex: 93782 TCD EI			email: cjmchale@cs.tcd.ie

mouse@lightning.mcrcim.mcgill.EDU (der Mouse) (03/10/91)

> How would I go about creating a transparent window in X.

Depends on what you want.

If the window is supposed to be completely nonexistent as far as
graphics output is concerned, look at InputOnly windows.

If you want to draw things in it, but don't care about changes
underneath showing through until the window is unmapped, consider an
InputOutput window with background None.

If changes underneath have to show through, try using SHAPE to shape
the window to fit the graphics, and then hope you're running on a
server that supports SHAPE (which, one hopes, is not much of a
constraint any longer).  Unfortunately, changing shapes tends to be
slow.  (If the transparent portions have to accept input just as if the
window were there, combine this with an InputOnly window.)

> It has to be the full size of the screen, or rather the same size as
> the root window, with no border...

InputOnly windows have no border.  Either of the other two solutions
may mean struggling to get the window manager out of your way;
depending on the window manager and the details of what you want to do,
this may range from trivial to impossible.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu

howcome@media-lab.media.mit.edu (Hakon Lie) (03/10/91)

In article <1991Mar8.130813.10424@vaxa.strath.ac.uk> cadp16@vaxa.strath.ac.uk writes:

   How would I go about creating a transparent window in X.

If your X server supports the Shape extension that came with R4 you
can create simple "transparent" windows by specifying a nonrectangular
shape. The extension is utilized by oclock and xeyes(R4). Here's an
outline of one way of doing this:

  /* check the extension is there */
  if(XShapeQueryExtension (dpy,&shape_event_base,
			       &shape_error_base))
    {
	/* create a pixmap where you specyfy the "mask" */
        shape_pm = XCreatePixmap(dpy,RootWindow(dpy,scr),
					   width,height,1);

	/* set mask values as defined in an image */
	XPutImage(dpy,shape_pm,gc,shape_p,0,0,0,0,width,height);

	/* tell the server to give the window a new shape */
	XShapeCombineMask(dpy,win,ShapeBounding,0,0,shape_pm,
				    ShapeSet);
     }

You can easily overload a poor server by specifying a complex shape
mask, e.g a checkerboard pattern.

See also "X11 nonrectangular window shape extension", by Keith
Packard, in mit/doc/extensions/shape.ms

-h&kon

Hakon W Lie              The first              howcome@media-lab.media.mit.edu
Media Lab, MIT E15-355      thing we do                          (617) 253-0312
Cambridge, MA 02139             let's kill all
USA                                   the lawyers.                --Shakespeare
--
					       _____
Hakon W Lie 				      /    
howcome@media-lab.media.mit.edu		----MIT Media Lab---
(617)253-0312				----an ec
					----s s  hnocracy----
					----o  ti
					     c   tute-of---
					      hi
					        stic--

farleyja@galactica.crd.ge.com (James Farley) (04/10/91)

     Has anyone compiled a listing of the resonses that were posted to this
group concerning how to implement transparent windows?  I remember 
seeing this issue raised more than a few times, with several responses,
but I can't find any of them in the "Frequently asked..." articles.

     What I need to do is have a window that acts like glass, and that can be
drawn on and erased from.  In other words, I need to overlap two windows, one
transparent and one opaque.  The transparent window contain the contents
of the opaque window, and any graphics drawn in the transparent window should
take precendence over the opaque window's contents (i.e. should behave as if 
drawn in the usual manner with a GXcopy GC function).  However, when pixels in
the transparent window are erased (i.e. set to the background value), I want
these pixels to be filled with the contents of the opaque window.  In essence,
I'm trying to implement a background pixel that is a function of another 
window's pixmap.

     Any ideas or past experiences are welcome and appreciated.

                                                     Jim Farley
                                                     farley@crd.ge.com