Fix switching from maximized to tile and back again, and keeping
the original window shape