godotengine / godotengine/godot

Set WINDOW_MODE_MINIMIZED not working on Linux

Open
#111,119 4 comments 0 reactions 0 assignees View on GitHub
bug platform:linuxbsd topic:platforms
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

4.5.stable.official.876b29033

### System information

Distributor ID: Ubuntu Description: Ubuntu 24.04 LTS Release: 24.04

### Issue description

I wrote a test coverage for handling window modes, but it fails on Linux distribution.
When setting the window mode to `WINDOW_MODE_MINIMIZED` the window is minimized but the `DisplayServer.window_get_mode()` returns `WINDOW_MODE_WINDOWED`
And when switch back to `WINDOW_MODE_WINDOWED` the window is still minimized.

### Steps to reproduce

Attach the script to a scene and run it by
`godot -S window_mode.tscn`
```gdscript
extends Node2D

func _process(_delta: float) -> void:
set_process(false)
debug(DisplayServer.WINDOW_MODE_WINDOWED)
DisplayServer.window_move_to_foreground()
await get_tree().create_timer(3).timeout

debug(DisplayServer.WINDOW_MODE_MINIMIZED)
await get_tree().create_timer(3).timeout

DisplayServer.window_move_to_foreground()
debug(DisplayServer.WINDOW_MODE_WINDOWED)
await get_tree().create_timer(3).timeout

debug(DisplayServer.WINDOW_MODE_MAXIMIZED)
await get_tree().create_timer(3).timeout

debug(DisplayServer.WINDOW_MODE_FULLSCREEN)
await get_tree().create_timer(3).timeout

debug(DisplayServer.WINDOW_MODE_MINIMIZED)
await get_tree().create_timer(3).timeout
get_tree().quit()

func debug(display_mode: DisplayServer.WindowMode) -> void:
DisplayServer.window_set_mode(display_mode)
var message := "{mode} curent mode: {current_mode} should be {expected_mode}".format({
"mode" : get_mode_as_string(display_mode),
"current_mode" : DisplayServer.window_get_mode(),
"expected_mode" :display_mode
})

prints(message)

func get_mode_as_string(display_mode: DisplayServer.WindowMode) -> String:
match display_mode:
DisplayServer.WINDOW_MODE_WINDOWED: return "WINDOW_MODE_WINDOWED"
DisplayServer.WINDOW_MODE_MINIMIZED: return "WINDOW_MODE_MINIMIZED"
DisplayServer.WINDOW_MODE_MAXIMIZED: return "WINDOW_MODE_MAXIMIZED"
DisplayServer.WINDOW_MODE_FULLSCREEN: return "WINDOW_MODE_FULLSCREEN"
DisplayServer.WINDOW_MODE_EXCLUSIVE_FULLSCREEN: return "WINDOW_MODE_EXCLUSIVE_FULLSCREEN"
_: return ""
```
## Results
- Windows 11
```
WINDOW_MODE_WINDOWED curent mode: 0 should be 0
WINDOW_MODE_MINIMIZED curent mode: 1 should be 1
WINDOW_MODE_WINDOWED curent mode: 0 should be 0
WINDOW_MODE_MAXIMIZED curent mode: 2 should be 2
WINDOW_MODE_FULLSCREEN curent mode: 3 should be 3
WINDOW_MODE_MINIMIZED curent mode: 1 should be 1
```
- Linux
```
WINDOW_MODE_WINDOWED curent mode: 0 should be 0
WINDOW_MODE_MINIMIZED curent mode: 0 should be 1
WINDOW_MODE_WINDOWED curent mode: 0 should be 0
WINDOW_MODE_MAXIMIZED curent mode: 2 should be 2
WINDOW_MODE_FULLSCREEN curent mode: 3 should be 3
WINDOW_MODE_MINIMIZED curent mode: 0 should be 1
```

### Minimal reproduction project (MRP)

n/a

Contributor guide

Open the contributing guide

Research direction

Start with the Linux implementation behind DisplayServer.window_set_mode() and window_get_mode(), using the provided GDScript reproduction to compare Linux with Windows behavior. Trace minimized-window state handling and verify that minimizing reports WINDOW_MODE_MINIMIZED and restoring returns to WINDOW_MODE_WINDOWED without regressing maximized or fullscreen modes.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, linux
Domain
desktop, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.