### 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
LPWSTR messageBuffer = nullptr;
	size_t size = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
			nullptr, id, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&messageBuffer, 0, nullptr);
	String msg = "Error " + itos(id) + ": " + String::utf16((const char16_t *)messageBuffer, size);
	LocalFree(messageBuffer);
	return msg;
}
static void track_mouse_leave_event(HWND hWnd) {
	TRACKMOUSEEVENT tme;
	tme.cbSize = sizeof(TRACKMOUSEEVENT);
	tme.dwFlags = TME_LEAVE;
	tme.hwndTrack = hWnd;
	tme.dwHoverTime = HOVER_DEFAULT;
	TrackMouseEvent(&tme);
}
bool DisplayServerWindows::has_feature(Feature p_feature) const {