Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!bywater!arnor!larios!db3l From: db3l@ibm.com (David Bolen) Newsgroups: comp.windows.x.motif Subject: Re: Getting the position (absolute) of a window Message-ID: Date: 4 Oct 90 14:32:33 GMT References: <15307@gouda.quad.com> Sender: news@arnor.uucp (NNTP News Poster) Organization: Laboratory Automation, IBM Thomas J. Watson Research Center Lines: 41 In-Reply-To: carl@quad1.quad.com's message of 3 Oct 90 18:57:20 GMT In article <15307@gouda.quad.com> carl@quad1.quad.com (Carl Priddy) writes: > I have a DrawingArea Widget which is the work area of a main window. > The main window is a child of an application shell. I need to get > the top left corner position of the Drawing Area relative to the > root window [...] > The problem I am seeing is that > XGetGeometry returns 0 for both the x and y positions for ALL of the > windows between DrawingArea and root. Using XtGetValues is no better. > Can anyone shed some light on this? I just recently ran up against the same problem. I tried XtGetValues, XGetGeometry and XGetWindowAttributes for all the windows I knew about, and always got (0,0) as a position. It turns out (I believe) that this is because mwm is a "reparenting window manager," which means that even what you think is your top level window (your application shell) has actually been forced to have a parent by mwm, which is the window mwm uses for handling the "decorations." Thus, even the position of your application shell is relative to a parent, and is at (0,0). I don't know how to find out what that parent is, and it doesn't show up when traversing the window hierarchy, at least with XtParent. Besides which, not all window managers will do this, so trying to determine the "hidden" parent isn't all that smart anyway. I finally settled for using the XTranslateCoordinates function to translate the coordinate (0,0) for my main window work area (which like you is a DrawingArea widget) to coordinates based on the root window. This seems to work just fine, and doesn't depend on the parentage of the widget. You can use DefaultRootWindow(-display-) as your root window target for the function if you don't have the root id already. -- David -- /-----------------------------------------------------------------------\ \ David Bolen / | Laboratory Automation, IBM Thomas J. Watson Research Center | / P.O. Box 218, Yorktown Heights, NY 10598 \ | - - - - - - - - - - - - M i t h r a n d i r - - - - - - - - - - - - | | Internet : db3l@ibm.com | Bitnet : db3l@yktvmv | | Usenet : uunet!bywater!arnor!larios!db3l | Phone : (914) 945-1940 | \-----------------------------------------------------------------------/