Fixes a bug when resizing a window.