[comp.windows.x] XtTranslateCoords

brossard%litsun2.epfl.ch@MITVMA.MIT.EDU (03/18/89)

                [Sent: Fri. 17/Mar./89  Time: 17:53]
        Either I found a bug or it doesn't do what I think it should do.
First, a few definitions:

        widget = XtCreatePopupShell( pn_title,
                        wmShellWidgetClass, toplevel, args, nargs);
        /*
         * Make a form widget.
         */
        form = XtCreateWidget("form", formWidgetClass, widget, NULL, 0);
followed by XtRealizeWidget, XtPopup and so on.

        The problem: I'm trying to find the location of the widget's
window on the screen.  Also worth mentionning, I'm using awm which
reparents windows (might be the source of the problem).  If I understand
correctly, I should be getting the x and y position of the left upper corner:

        XtTranslateCoords( widget, 0, 0, &shellx, &shelly );

        The only thing I get is the ORIGINAL position of the window,
no amount of moving the window changes the result.  I assume this is
related to awm reparenting the window, but I'm not sure.  So is this
a bug?

        Alternate question, how am I supposed to get the window location
of a widget?

        1- XtTranslateCoords    -> doesn't work right now
        2- XGetWindowAttributes(display, XtWindow(widget), &attr);
                gives (0,0) -> relative to parent (due to awm!)
                so followed by:
            XQueryTree(display, XtWindow(pn->pn_shellwidget), &root,
                        &parent, &children, &number);
            if( parent != root ) XGetWindowAttributes(display, parent, &attr);
            (now good coordinates in (attr.x, attr.y), independent of
             which window manager is used)
        3- XTranslateCoordinates( display, XtWindow(widget),
                        RootWindow(display, 0),
                        0, 0, &shellx, &shelly, &w );
            (which works, but seems unduly complicated, and note the hardcoded
            0 in RootWindow (see previous posting)).
        4- ??


        Additionnal info: SunOS3.5, SUN3/60 B&W, X.V11R3 patch level 9 +
                Purdue speed ups, awm patch level 9.

        Program available on request (modified Xpostit).

                                                Alain Brossard
                                                brossard@litsun2.epfl.ch

swick@ATHENA.MIT.EDU (Ralph R Swick) (03/18/89)

>         Alternate question, how am I supposed to get the window location
> of a widget?

use XTranslateCoordinates (or a different wm :-) until the next Xt
fix is published.