title: How to center Dialog into parent Window in compose?
body: <p>In compose desktop we have Dialog and AlertDialog.</p>
  <p>If use Dialog, it has no parent and it's aligned center of the screen by default. To align it to window center we can calculate diffirence between window and dialog center point offset and get offset need to be added for dialog start position:</p>
  <pre><code>fun getOffset(wState: WindowState, dState: DialogState): DpOffset {
      
      val winCenterPoint = DpOffset(
          wState.position.x + wState.size.width / 2,
          wState.position.y + wState.size.height / 2
      )
      
      val dlgCenterPoint = DpOffset(
          dState.position.x + dState.size.width / 2,
          dState.position.y + dState.size.height /2
      )
      
      return winCenterPoint - dlgCenterPoint
      
  }
  </code></pre>
  <p>But here is a problem: If Window or Dialog size is unspecified, we're not be able to calculate offset. Also if Window/Dialog is centered on the screen - state.position will return Alignment instead of Offset.</p>
  <p>If use AlertDialog it centered by parent bounds. This one throw exception when I set as buttons parameter custom composable dialog:</p>
  <p><a href="https://i.stack.imgur.com/Vx7qa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Vx7qa.png" alt="enter image description here" /></a></p>
  <p>AlertDialog based on Popup underhood, but when I set same composables to Popup it doesn't crash, think it's someting with measuring inside window.</p>
  <p>If somebody have a better way to align Dialog to Window center, share pls your knowlage.</p>