MainWindow: fix clamping function and avoid saving position/size if maximized or minimized