[comp.windows.x] XtUnmapWidget

y2@DINORAH.WUSTL.EDU (Yeong-Yeong Liu) (07/23/88)

I have a problem when I was trying to use XtUnmapWidget, any help
will be appreciated.  I created a menu page which has multiple
choices, however, some of the choices were not implemented yet.
So I created a label widget for message which gets mapped for
few seconds then unmapped when an unimplemented function is
chosen.  My problem is that I can't get the label widget's text
to show up.  My program flow as follows:
      .
      .
static Widget w2;
      .
      .
w = XtCreateWidget("mainwidget",formWidgetClass,toplevel,args,n);
   XtSetArg(...);n++;		/* several XtSetarg() calls*/
   w1 = XtCreateWidget("panel",formWidgetClass,w,args,n);
      XtSetArg(...);n++;	/* several calls including one set callback
				   to function c1 */		
      m1 = XtCreateWidget("choice1",commandWidgetClass,w1,args,n);
      XtSetArg(...);n++;	/* several calls including one set callback
				   to function c2 */
      m2 = XtCreateWidget("choice2",commandWidgetClass,w1,args,n);
      XtSetArg(...);n++;	/* several calls including one set callback
				   to function c3 */ 
      m3 = XtCreateWidget("choice3",commandWidgetClass,w1,args,n);
      .
      .
   XtSetArg(...);n++;		/* several calls including one set
				   XtNmappedWhenManaged to False
				   AND XtNfromVert to w1 (so w2 will
				   be below w1) */
   w2 = XtCreateWidget("not implemented",labelWidgetClass,w,args,n);
      .
      .
   XtManageChild(w);
   XtRealizeWidget(toplevel);
   XtMainLoop();
   }

Assume choice 2 & 3 are not implemented, my code looks like this:

void c2(w,client_data,call_data)
   Widget w;
   caddr_t client_data;
   caddr_t call_data;
   {
   NotImplemented();
   }

void c3(w,client_data,call_data)
   Widget w;
   caddr_t client_data;
   caddr_t call_data;
   {
   NotImplemented();
   }

void NotImplemented()
   {
   XtMapWidget(w2);
   XBell(dpy,50);
   XFlush(dpy);
   sleep(2);
   XtUnmapWidget(w2);
   XFlush(dpy);
   }

Every time when I activated command widget m2, the program came to
function c2 then it maps, rings bell, waits two seconds and unmaps.
It's all there execpt the text --- "not implemented".  If I remove
XtSetArg for XtNmappedWhenManaged so it will be left as True by
default, then "not implemented" appear below w1 immediately.
Activating command m2 starts XtMapWidget(w2) (which does nothing
because w2 is already mapped), rings bell, waits, unmaps (they all
worked).  After that last XtUnmapWidget(w2), I will not see 
"not implemented" text string again.

Thanks for any suggestion.

Y Liu
	{uunet...}!wucs1!dinorah!y2	or
	wucs1.wustl.edu!dinorah!y2	or
	y2@dinorah.wustl.edu		or
	314-362-2950

diamant@hpfclp.SDE.HP.COM (John Diamant) (07/25/88)

> void NotImplemented()
>    {
>    XtMapWidget(w2);
>    XBell(dpy,50);
>    XFlush(dpy);
>    sleep(2);
>    XtUnmapWidget(w2);
>    XFlush(dpy);
>    }
> 
> Every time when I activated command widget m2, the program came to
> function c2 then it maps, rings bell, waits two seconds and unmaps.
> It's all there execpt the text --- "not implemented".

First of all, you might want to consider using XtPopup on a transientShell
widget rather playing with mapped when managed within a form (your choice,
but it would allow it to interact with a window manager better).

Anyway, your problem is that you are not allowing the labelWidget to get
an Expose event before you unmap the widget, so it never knows it is supposed
to draw the contents.  What you probably need to do is set a timer using
XtAddTimeOut rather than doing a sleep.  This way, you could have your function
return, and XtMainLoop would give the labelWidget a chance to draw its
contents.  Then, when the timeout occurs, you will have registered a function
to unmap the widget and everything will work out as you had intended.


John Diamant
Software Development Environments
Hewlett-Packard Co.		ARPA Internet: diamant@hpfclp.sde.hp.com
Fort Collins, CO		UUCP:  {hplabs,hpfcla}!hpfclp!diamant

bw@hpcvlx.HP.COM (Bill Wilhelmi) (07/26/88)

I don't know where you execute XtManageChild() for any of the 
widgets except w.  Did you mean to execute XtManageChildren(w)?

Without seeing all of your code, it's hard to tell what is 
going on.  If you would like to send me a copy of your code,
I would be happy to take a crack at it.  

Of course, if you have found a solution by now, disregard.



Bill Wilhelmi    
Hewlett-Packard Company
Corvallis Workstation Operation
Corvallis, Oregon 
______________________________________________________________________________
bw@hpcvlx.hp.com
UUCP:{ihnp4|cbosgd|allegra|decvax|gatech|sun|tektronix}!hplabs!hp-pcd!hpcvlx!bw
USnail   : 1000 N.E. Circle Blvd., Corvallis, Oregon, 97330, USA

   

koe@kivax.UUCP (Diana Koehler) (11/08/90)

hello,

I have an application, which changes its "Map"-State using
XtMapWidget() and XtUnmapWidget().
This works fine with X11.3 and Motif.1.0.

Now I recompiled and linked my application with X11.4 and Motif.1.1
and got the following "Protocol-Error".

X Protocol error:  BadMatch
  Major opcode of failed request:  42 (X_SetInputFocus)
  Serial number of failed request:  373
  Current serial number in output stream:  375

I do NOT CALL XSetInputFocus() myself.

Any Help ?????

Thanks

Diana

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

Diana Koehler                     Tel.:   +49 7721 867034
Mannesmann Kienzle GmbH
Abt. 011.2                        e-mail: koe@kivax.UUCP
Postfach 1640                             ..!mcsun!unido!kivax!koe
D-7730 VS-Villingen                       ..!uunet!unido!kivax!koe