### 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
old_x = mm->get_position().x;
			old_y = mm->get_position().y;
			if (windows[window_id].window_has_focus || window_get_active_popup() == window_id) {
				Input::get_singleton()->parse_input_event(mm);
			}
			return 0; 
		} break;
		case WM_MOUSEMOVE: {
			if (windows[window_id].block_mm) {
				break;
			}
			if (mouse_mode == MOUSE_MODE_CAPTURED && use_raw_input) {
				break;
			}
			if (Input::get_singleton()->is_emulating_mouse_from_touch()) {
				
				LPARAM extra = GetMessageExtraInfo();
				if (IsTouchEvent(extra)) {
					break;
				}
			}
			DisplayServer::WindowID over_id = get_window_at_screen_position(mouse_get_position());
			if (windows.has(over_id) && !Rect2(window_get_position(over_id), Point2(windows[over_id].width, windows[over_id].height)).has_point(mouse_get_position())) {
				
				over_id = INVALID_WINDOW_ID;
			}
			if (window_mouseover_id != over_id) {
				
				if (mouse_mode != MOUSE_MODE_CAPTURED) {
					if (window_mouseover_id != INVALID_WINDOW_ID && windows.has(window_mouseover_id)) {