Automatic window sizing