[comp.windows.x] How can an application know its TRUE location?

spencer@heinlein.osc.edu (Stephen Spencer) (09/04/89)

(Reply to 'spencer@heinlein.cgrg.ohio-state.edu' please.)

How can an application know that is has been moved by the window manager?
For example, (and this is under 'awm' on a Sun 3/60, X.V11R3, with Xt stuff)
I can start up an application (transient Shell Widget, bulletinWidget and
several pushbuttonWidgets on the bulletin 'board').  The application gets 
drawn at (x, y) (the way I have 'awm' set up I can choose where the application
comes up by moving the mouse and single-clicking).
I can do a XtGetValues() with XtNx, XtNy as parameters on 'toplevel' and
get the proper x,y coordinates of the application.  Now.  I use the window 
manager to move this application.  Doing the XtGetValues() as before yields
the same x, y coordinates even though I've moved the application.

Is there some simple way of determining the TRUE location of an application?
Sorry if this is a simple question to answer, but I'm scratchin' my head on 
this one.  Thanks for any help you all can offer.



-=-
Stephen N. Spencer      |"For a successful technology, reality must take
ACCAD, 1224 Kinnear Rd. | precedence over public relations, for Nature
Columbus OH 43212       | cannot be fooled."     - Richard P. Feynman
spencer@heinlein.cgrg.ohio-state.edu OR spencer@cis.ohio-state.edu

kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (09/07/89)

> How can an application know that is has been moved by the window manager?
> For example, (and this is under 'awm' on a Sun 3/60, X.V11R3, with Xt stuff)
> I can start up an application (transient Shell Widget, bulletinWidget and
> several pushbuttonWidgets on the bulletin 'board').  The application gets 
> drawn at (x, y) (the way I have 'awm' set up I can choose where the application
> comes up by moving the mouse and single-clicking).
> I can do a XtGetValues() with XtNx, XtNy as parameters on 'toplevel' and
> get the proper x,y coordinates of the application.  Now.  I use the window 
> manager to move this application.  Doing the XtGetValues() as before yields
> the same x, y coordinates even though I've moved the application.

You have run into a bug in the MIT R3 Intrinsics implementation, actually it is
more of a limitation than a bug.  Since the ICCCM was not fully specified when
R3 went out and there were no ICCCM compliant window managers, we were not able
to get enough communication between the Intrinsics and the window manager.  As a
result the window managers do not tell the Intrinsics when one of the top level
windows of an application has been moved.  Thus when you move a window the shell
widget gets confused as to what its real location is.  This also causes
XtTranslateCoords() to have problems.  Now that we have a solid ICCCM and a few
compliant window managers we have fixed this bug, and you should have no
problems when using the R4 Intrinsics.

> Is there some simple way of determining the TRUE location of an application?

Yep, use XTranslateCoordinates() on position 0, 0 of the shell.  This will give
you its true location with respect to the root window.  Be aware that this
method makes a round trip to the X server so that doing it a lot is going to
slow down your application.  The Toolkit translation routines do not make this
round trip, this is why using those is better (Assuming that they work :-).

> Sorry if this is a simple question to answer, but I'm scratchin' my head on 
> this one.

Simple questions I don't mind, redundant questions, however...

ICCCM -> Inter - Client Communications Conventions Manual


						Chris D. Peterson     
						MIT X Consortium 

Net:	 kit@expo.lcs.mit.edu
Phone:   (617) 253 - 9608	
Address: MIT - Room NE43-213