If the window is maximized, we can't change the size immediately. In that case, we set a bool and wait for the state to change before triggering the resize.