Path: utzoo!attcan!uunet!mcsun!ukc!harrier.ukc.ac.uk!rlh2 From: rlh2@ukc.ac.uk (Richard Hesketh) Newsgroups: comp.windows.x Subject: Where is my shell widget really positioned? Message-ID: <4352@harrier.ukc.ac.uk> Date: 7 Apr 90 17:03:02 GMT Reply-To: rlh2@ukc.ac.uk (Richard Hesketh) Organization: Computing Lab, University of Kent at Canterbury, UK. Lines: 79 The following test program shows up a problem when it comes to knowing where shells are positioned in Xt. Compile the program with cc -o postest postest.c -lXaw -lXmu -lXt -lXext -lX11 .. and run it with the following .. postest -geometry +200+200 Now press the button. What value do you get printed? Under twm (X11R4-no fixes), for me, the following is printed: Position of toplevel returned by GetValues() = +202+221 Now this is not what I gave it! Infact this is the *real* position of the toplevel window on the screen. Who is correct? Is the toolkit correct for returning the absolute position on the screen or should it return the *real* geometry .. taking into account that the window manager has reparented the window and decorated it (I know the shellWidget knows about reparenting already) ? Is the window manager correct in moving my window down and to the left to make way for its decorations? I ask this because I have an application that needs to save state and wants to know where it is so that next time it is started up it can be placed in the same place. If I take the current values returned by GetValues() my windows gradually drift off the screen! Surely my program should not need to know that a window manager is running (what is the shell widget for!) and have walk the window tree to find the logical position on the screen? Has the idea that applications do not need to know that a window manager is running been dropped 8-) ? I would really like to know whether I need to walk the window heirarchy or not. Thanks, Richard Hesketh : @nsfnet-relay.ac.uk:rlh2@ukc.ac.uk : rlh2@ukc.ac.uk ..!mcvax!ukc!rlh2 --- Computing Lab., University of Kent at Canterbury, Canterbury, Kent, CT2 7NF, United Kingdom. Tel: +44 227 764000 ext 3682/7620 ----- #include #include /* ARGSUSED */ position(w, client_data, call_data) Widget w; XtPointer client_data, call_data; { Position x, y; XtVaGetValues(XtParent(w), XtNx, &x, XtNy, &y, NULL); printf("Position of toplevel returned by GetValues() = +%d+%d\n",x, y); } main(argc, argv) unsigned int argc; char **argv; { Widget toplevel, but; toplevel = XtInitialize("bugtest", "BugTest", (XrmOptionDescRec *)NULL, 0, &argc, argv); but = XtCreateManagedWidget("bugTestLabel", commandWidgetClass, toplevel, (ArgList)NULL, 0); XtAddCallback(but, XtNcallback, position, (XtPointer)NULL); XtRealizeWidget(toplevel); XtMainLoop(); } -----