Use the same gravity calculation everywhere

This also enables the use of :top, :bottom, :left and :right gravity for
the message and input window.
Merge pull request #113 from jorams/unify-gravity

Use the same gravity calculation everywhere