Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker!bloom-beacon!pisa.intecs.it!cinzia From: cinzia@pisa.intecs.it (Cinzia bonini) Newsgroups: comp.windows.x Subject: Transparent windows Message-ID: <9007191624.AA00188@intecs.uucp> Date: 19 Jul 90 16:24:31 GMT Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 186 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?