title: X11: XGetWindowAttributes: window position has offset
body: <p>I'm using Gnome on Ubuntu 20.04. When I use <code>XGetWindowAttributes()</code>, the window position I get has an offset, as if the window has a thick (invisible) margin, but the offset is different for different windows.</p>
  <p>I looked at the component <code>border_width</code> in the window attributes, but it is always zero. I tried <code>XTranslateWindowCoordinates()</code> (<a href="https://stackoverflow.com/a/23940869/3852630">https://stackoverflow.com/a/23940869/3852630</a>), but it doesn't affect the positions.</p>
  <p>To give some details, maybe they are relevant: The window I look at comes from <code>XGetInputFocus()</code>, and I use the code from this answer <a href="https://stackoverflow.com/a/39549363/3852630">https://stackoverflow.com/a/39549363/3852630</a> to get the parent of the focused window. Gnome draws a shadow around the windows, but that should be the same for all windows.</p>
  <p>Any idea where I can get the information on the size of this margin or on the true window position?</p>
  <p>Thanks a lot!</p>
  <hr />
  <p>In response to datenwolf's comments, here are the trees. I get the focused window with <code>XGetInputFocus</code> and then go down the window tree with <code>XQueryTree</code> until I reach a window that has the root window as parent (see link above), the last one in the tree lists below. I print the window position and window size and the window's name (if it has one); <code>n</code> is the loop index of the descent in the tree.</p>
  <p>This is the tree for an emacs window (has a small border, i.e. there's a small position offset):</p>
  <pre><code>n=1 x=-1 y=-1 w=1 h=1
  n=2 x=10 y=45 w=752 h=714 name = emacs@laptopC3
  n=3 x=3064 y=104 w=772 h=769
  </code></pre>
  <p>The line <code>n=3</code> has the window position which fits with my dual monitor setup, but the line <code>n=2</code> gives a smaller size (but totally wrong position). I wonder what the window in line <code>n=1</code> is.</p>
  <p>This is the tree for a terminal (has a large border):</p>
  <pre><code>n=1 x=-1 y=-1 w=1 h=1
  n=2 x=2889 y=390 w=786 h=533 name = Terminal
  </code></pre>
  <p>Nothing to see, except the weird window for <code>n=1</code>.</p>
  <p>This is a Tcl/Tk application (which has a tiny border):</p>
  <pre><code>n=1 x=1 y=38 w=1026 h=770 name = PNGShow-6-6
  n=2 x=3192 y=234 w=1028 h=809
  </code></pre>
  <p>Note that here we have no weird window for <code>n=1</code>.</p>
  <p>I don't see a consistent effect.</p>