Fallback to window height when positioning dialogs

This prevents dialogs from being half hidden at the top of the screen.

![](https://i.imgur.com/YIUj0gg.png)

cc @PVince81 @DeepDiver1975 @karlitschek