title: Obtaining Windowed window's Position in X-window System?
body: <p>Yes. I tried both, that using "XGetWindowAttributes()" and "XGetGeometry()", but it gives only x,y value at always 0,0.</p>
  
  <p>But when I moved my window to middle of the entire screen, in that case my returning value should be 800, 450 around those values if my screen resolution is 1600, 900. However it always return 0,0.</p>
  
  <p>Following is the code I tested and below that I attached a photo where drawn red dot explains the point in 2D screen coordinate I want to get.</p>
  
  <pre><code>int* getWindowPos(Display *dpy, Window *curWin) {
      int winPos[2]; 
      unsigned int width, height, bwidth, depth;
      Window root;
  
      root =  XRootWindow(GLWin.dpy, 0);
  //    Window myWin;
  //    myWin = XRootWindow(dpy, 0);
  
      //XWindowAttributes xwa;
      //XGetWindowAttributes(dpy, *curWin, &amp;xwa);
      XGetGeometry(dpy, *curWin, &amp;root, &amp;winPos[0], &amp;winPos[1], &amp;width, &amp;height, &amp;bwidth, &amp;depth );
     // printf("%d %d\n", xwa.x, xwa.y);
  
      return winPos;
  
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/VWgAM.jpg" alt="I want to get at least 2D screen coordinate of top-left position of this window!"></p>