y2@DINORAH.WUSTL.EDU (Yeong-Yeong Liu) (12/15/88)
I was testing a program which pops up a menu by pressing button 1 on a command widget. The popup widget was deliberately placed near the command widget which activated it. Program seems worked fine until I repositioned the top level window to a different location by using "Move" function under uwm. The popup insists on appearing at the same old location no matter where its ancestors are. I traced the problem with debugger, it turned out the toplevel widget x and y positions were never updated after the uwm Move. I have used XtTranslateCoords in other application and didn't have this problem. Debugger told me the toplevel widget x,y position was always updated after the move in these applications. Help ? TIA Yeong Yeong Liu {uunet...}!wucs1!dinorah!y2 or wucs1.wustl.edu!dinorah!y2 or y2@dinorah.wustl.edu or 314-362-2950 Here is my test program which didn't work: ========================================== #include <X11/Intrinsic.h> #include <X11/IntrinsicP.h> #include <X11/StringDefs.h> #include <X11/Cardinals.h> #include <X11/Command.h> #include <X11/Box.h> #include <X11/Label.h> #include <X11/Shell.h> #include <stdio.h> /* ARGSUSED */ void done(w, str, dummy) Widget w; caddr_t str; caddr_t dummy; { exit(0); } /* ARGSUSED */ void Popup(w, client_data,call_data) Widget w; caddr_t client_data,call_data; { Position x, y; Arg args[2]; Widget popupshell; popupshell = XtNameToWidget(w,client_data); x = 50; y = 10; XtTranslateCoords(w,x,y,&x,&y); XtMoveWidget(popupshell,x,y); XtPopup(popupshell,XtGrabNone); } /* ARGSUSED */ void Popdown(w, client_data,call_data) Widget w; caddr_t client_data,call_data; { Widget popupshell; popupshell = (Widget)atoi(client_data); XtPopdown(popupshell); } void main(argc, argv) int argc; char **argv; { Widget toplevel, menu_bar, button, popupbutton2; Widget popupshell, menu; Arg arg[5]; char addr[10]; static XtCallbackRec menu2callbacks[] = { {Popup,(caddr_t)"menu2"}, {NULL,NULL} }; toplevel = XtInitialize( "popup_test", "XPopupTest", NULL,0,&argc, argv ); /**** menu bar ****/ menu_bar = XtCreateManagedWidget( "menu_bar", boxWidgetClass, toplevel, NULL, ZERO); /**** menu bar items ****/ button = XtCreateManagedWidget( "quit", commandWidgetClass, menu_bar, NULL, ZERO); XtAddCallback(button, XtNcallback, done, (caddr_t)NULL); XtSetArg(arg[0],XtNcallback,menu2callbacks); popupbutton2 = XtCreateManagedWidget( "Pop-ups", commandWidgetClass, menu_bar,arg, ONE ); /**** popup menu2 ****/ popupshell = XtCreatePopupShell("menu2", overrideShellWidgetClass, popupbutton2,(Arg *)0, ZERO); menu = XtCreateManagedWidget( "PopupMenu", boxWidgetClass, popupshell, (Arg *)0, ZERO); /**** popup menu2 items ****/ /* option 1 */ button = XtCreateManagedWidget( "choice1", commandWidgetClass, menu, (Arg *)0, ZERO ); /* option 2 */ button = XtCreateManagedWidget( "choice2", commandWidgetClass, menu, (Arg *)0, ZERO ); /* option 3 */ sprintf(addr,"%d",popupshell); menu2callbacks[0].callback = Popdown; menu2callbacks[0].closure = &addr[0]; XtSetArg(arg[0],XtNcallback,menu2callbacks); button = XtCreateManagedWidget( "quit", commandWidgetClass, menu, arg, ONE ); XtRealizeWidget(toplevel); XtMainLoop(); }
rlh2@ukc.ac.uk (Richard Hesketh) (12/16/88)
In article <8812141923.AA03161@dinorah.wustl.edu> y2@DINORAH.WUSTL.EDU (Yeong-Yeong Liu) writes: >... Program seems worked fine until I >repositioned the top level window to a different location by using >"Move" function under uwm. The popup insists on appearing at the same >old location no matter where its ancestors are. This certainly seems to a problem with the toolkit not being informed of an update in the geometry of the window of the popup shell. If you iconize the application and then de-iconize it, any further pop ups will appear in the right place (until moved again!). Therefore it appears that uwm won't inform the window of a geometry change unless it is really forced to? This problem has been around since R2, I assume it is being look at? >Here is my test program which didn't work: > > .... > y = 10; > XtTranslateCoords(w,x,y,&x,&y); > XtMoveWidget(popupshell,x,y); In R3 the XtMoveWidget call should be replaced by an XtSetValues call. This should only be used in R2 sources due to a bug in the R3 Shell widget which has been fixed in R3. Only composite widget classes should make direct calls to XtResizeWidget or XtMoveWidget, everybody else should use XtSetValues or XtMake{Resize, Geometry}Request's. This enforces correct use of class built geometry handlers. Richard Hesketh : rlh2@ukc.ac.uk ..!mcvax!ukc!rlh2 --- Computing Lab., University of Kent at Canterbury, Canterbury, Kent, CT2 7NF, England.