Path: utzoo!attcan!uunet!samsung!sol.ctr.columbia.edu!lll-winken!sun-barr!newstop!texsun!texbell!vector!egsner!ntpal!amy From: amy@ntpal.UUCP (Dana Amy) Newsgroups: comp.windows.x Subject: Window's absolute position Keywords: position, x, y, absolute Message-ID: <485@ntpal.UUCP> Date: 14 Jun 90 16:49:34 GMT Organization: Bell Northern Research, Inc., Richardson, TX Lines: 60 I am a beginning X-programmer, and I need to find the absolute position of a newly created window. I have a sneaking suspicion that there is a simple, straightforward method for this, but I have been unable to discover it. My first thought was to traverse the window's ancestorial tree and add up all of the x,y offsets: Widget window, toplevel; Window win, win_root, win_parent; Display *disp; Status rc; int x, y, win_x, win_y, *win_kids, nkids; unsigned int win_w, win_h, win_border_w, win_depth; x = 0; y = 0; win = XtWindow(window); root = RootWindowOfScreen(XtScreen(toplevel)); disp = XtDisplay(toplevel); /* Loop through all windows until the root window is reached */ while (win != root) { /* Add the x,y offset of the current window */ rc = XGetGeometry(disp, win, &win_root, &win_x, &win_y, &win_w, &win_h, &win_border_w, &win_depth); x += win_x + win_border_w; y += win_y + win_border_w; /* Find the parent of the current window */ rc = XQueryTree(disp, win, &win_root, &win_parent, &win_kids, &nkids); XFree(win_kids); win = win_parent; } /* Add the x,y offset of the root window */ rc = XGetGeometry(disp, win, &win_root, &win_x, &win_y, &win_w, &win_h, &win_border_w, &win_depth); x += win_x + win_border_w; y += win_y + win_border_w; but while the other information returned by XGetGeometry looks valid, the win_x and win_y values are ALWAYS 0. The window opens up in the middle of the screen. What is going on? Is it possible for the display to be offset??? I am using X11R4 on a Sun Sparc. Please e-mail responses if possible. I will summarize if enough interest is shown in this problem. Thank you in advance! -- Dana Amy | "A rock pile ceases to be a rock pile amy%ntpal@egsner.cirr.com | the moment a single man contemplates it, ntpal!amy@egsner.cirr.com | bearing within him the image of a cathedral." ...!texbell!egsner!ntpal!amy | - Antoine de Saint-Exupery