Taking a look at the built in windmove functions shows that Emacs has a
built in function for swapping windows called `window-swap-states`.
Using this ensures the window state is maintained.
Ref: #6023
Co-authored-by: luveti <luveti@users.noreply.github.com>