Only resize a window when actually needed