title: How to get a text position by x,y coordinates in a specified buffer?
body: <p>I have coordinates of some point in the buffer : x,y relatively to the beginning of a window;
  Ho to get a textual-position (offset of the beginning of the buffer) by these relative coordinates?</p>
  
  <p>I. e.:</p>
  
  <p>--------------- starting of the buffer</p>
  
  <pre><code>sdfv efrv s
  </code></pre>
  
  <p>========================================= &lt;-- window start border</p>
  
  <pre><code>s!df verg 34v dc
  sd sdf 
  </code></pre>
  
  <p>========================================= &lt;-- window end border</p>
  
  <p>If the point is in the exclamation mark position, than x = 1, y = 0, position = 13. Now i know the (x,y)=(1,0), how to get a position?</p>
  
  <p><strong>edit</strong>(in response to Stefan)<strong>:</strong>
  This coordinates are come from event, fairing on mause-1 down. I take it from a function <code>tmm-menubar-mouse</code>. the whole event looks like this:</p>
  
  <p>(mouse-1 (nil menu-bar (45 . 0) 15023 nil 2924 (45 . 0) nil (0 . 0) (1 . 0)))</p>
  
  <p>The problem is, that due to a <a href="https://stackoverflow.com/questions/12317844/disable-help-menu-on-mouse-button-at-a-right-side-with-x-coord-0x7f">bug</a> some coordinates are calculated wrongly, and i recalculate them, but then i have to get a textual position in order to transmit a new event to <code>mouse-drag-region</code>. I get window by <code>window-at</code>, and recalculate absolute coordinates to relative substracting window up-left angle from them.</p>