Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!mailrus!tut.cis.ohio-state.edu!bloom-beacon!DINORAH.WUSTL.EDU!y2 From: y2@DINORAH.WUSTL.EDU (Yeong-Yeong Liu) Newsgroups: comp.windows.x Subject: wrong window coordinates after uwm "Move" Message-ID: <8812141923.AA03161@dinorah.wustl.edu> Date: 14 Dec 88 19:23:55 GMT Sender: daemon@bloom-beacon.MIT.EDU Organization: The Internet Lines: 133 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 #include #include #include #include #include #include #include #include /* 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(); }