### Godot version

v4.0.2.stable.official [7a0977c]

### System information

Window 10

### Issue description

If your project is set to `WINDOW_MODE_FULLSCREEN` in project settings, the first time you try to switch mode for `WINDOWED`, it will not switch properly.


### Steps to reproduce

1. Create a new project
2. Change project settings `Display > Window > Mode` for `FullScreen`
3. Run the following code :

Code that reproduce the issue:
```
func _ready():
	DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
	DisplayServer.window_set_size(Vector2i(800,600))
``` 

## Workaround
Calling the `window_set_mode` twice solve the issue...

```
func _ready():
	DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
	DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
	DisplayServer.window_set_size(Vector2i(800,600))
``` 


### Minimal reproduction project

N/A: reproduction steps are trivial
f->get_buffer((uint8_t *)&data_small.write[0], bytecount_small);
	HICON icon_small = CreateIconFromResource((PBYTE)&data_small.write[0], bytecount_small, TRUE, 0x00030000);
	ERR_FAIL_COND_MSG(!icon_small, "Could not create 16x16 @" + itos(small_icon_cc) + " icon, error: " + format_error_message(GetLastError()) + ".");
	
	int err = 0;
	SetLastError(err);
	SendMessage(windows[MAIN_WINDOW_ID].hWnd, WM_SETICON, ICON_SMALL, (LPARAM)icon_small);
	err = GetLastError();
	ERR_FAIL_COND_MSG(err, "Error setting ICON_SMALL: " + format_error_message(err) + ".");
	SendMessage(windows[MAIN_WINDOW_ID].hWnd, WM_SETICON, ICON_BIG, (LPARAM)icon_big);
	err = GetLastError();
	ERR_FAIL_COND_MSG(err, "Error setting ICON_BIG: " + format_error_message(err) + ".");
	memdelete(icon_dir);
}
void DisplayServerWindows::set_icon(const Ref<Image> &p_icon) {
	_THREAD_SAFE_METHOD_
	ERR_FAIL_COND(!p_icon.is_valid());
	if (icon != p_icon) {
		icon = p_icon->duplicate();
		if (icon->get_format() != Image::FORMAT_RGBA8) {
			icon->convert(Image::FORMAT_RGBA8);
		}
	}
	int w = icon->get_width();
	int h = icon->get_height();
	
	int icon_len = 40 + h * w * 4;
	Vector<BYTE> v;
	v.resize(icon_len);
	BYTE *icon_bmp = v.ptrw();