title: X11: waiting until a window is visible?
body: <p>I'm running X across a slow network connection.  How can I tell when a window has become visible?  I need to wait so that I can perform another operation on the visible window.</p>
  
  <pre><code>xterm -T foo &amp;
  # how to flush the display, or wait until the window is visible?
  # polling the visibility would be acceptable as well
  xmovewindow foo  10 20 
  </code></pre>
  
  <p>update: Thanks to Jim Lewis, here's a quick shell function that does the trick.</p>
  
  <pre><code>function xwait() {
      while ! xwininfo -name $1|grep 'Map State: IsViewable';do sleep 1;done
  }
  xterm -T foo &amp;
  xwait foo
  xmovewindow foo  10 20 
  </code></pre>