godotengine / godotengine/godot
Window.mode doesn't change of value when switching between borderless and windowed.
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
v4.2.2.stable.flathub [15073afe3]
### System information
Linux v4.2.2.stable.flathub [15073afe3]
### Issue description
Switching of display mode from borderless and windowed doesn't change (immediately) the value of Window.mode.
By doing further testing, I noticed it actually change, but after some time.
```gdscript
_toggle_borderless()
print(get_window().mode) // prints 2
_toggle_windowed()
print(get_window().mode) // prints 2
_toggle_exclusive_fullscreen()
print(get_window().mode) // prints 4
_toggle_windowed()
await get_tree().create_timer(1.0).timeout
print(get_window().mode) // prints 0
func _toggle_exclusive_fullscreen() -> void:
get_window().mode = Window.MODE_EXCLUSIVE_FULLSCREEN if (true) else Window.MODE_WINDOWED
func _toggle_borderless() -> void:
get_window().mode = Window.MODE_EXCLUSIVE_FULLSCREEN if (false) else Window.MODE_WINDOWED
get_window().mode = Window.MODE_MAXIMIZED if (true) else Window.MODE_WINDOWED
get_window().borderless = true
func _toggle_windowed() -> void:
get_window().mode = Window.MODE_MAXIMIZED if (false) else Window.MODE_WINDOWED
get_window().borderless = false
get_window().mode = Window.MODE_EXCLUSIVE_FULLSCREEN if (false) else Window.MODE_WINDOWED
```
It's not a breaking problem, but I spotted it while writing unit test for my script handling the display. I couldn't properly test the switch between windowed and borderless because of this.
### Steps to reproduce
See the code above or download the display_test project.
You have buttons to switch of mode with a print to show the problem. On ready, it will run the code above.
### Minimal reproduction project (MRP)
[display_test.zip](https://github.com/user-attachments/files/16493175/display_test.zip)
Contributor guide
Research direction
Start by running the attached display_test project and the provided GDScript sequence to reproduce the delayed Window.mode value when switching between borderless and windowed modes. Trace the Window mode and borderless updates in Godot's desktop window handling; done means the reported mode reflects each switch immediately, including in the described sequence.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- godot
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100