godotengine / godotengine/godot

OS.move_to_trash() makes window lose and gain focus

Open
#99,552 2 comments 0 reactions 0 assignees View on GitHub
bug confirmed platform:windows topic:editor
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

Reproduced in 4.3 stable and 4.2 stable

### System information

Godot v4.3.stable - Windows 10 - GLES3 (Compatibility)

### Issue description

calling the OS.move_to_trash() function will cause the application window to lose and gain focus.

there are more issues with the window losing/gaining focus (see #99438), but I dont know if thats related.

### Steps to reproduce

create a node and attache a script with the following code:

```gdscript
func _ready() -> void:
get_window().focus_entered.connect(func_print.bind("enter"))
get_window().focus_exited.connect(func_print.bind("exit"))

await get_tree().create_timer(0.5).timeout
OS.move_to_trash("res://not_exists.txt") # this will also cause an error 124 in the debug (note: error 124 is not defined in the return values btw), because input was not a global path, but it does not matter for the demonstration (window always loses & gains focus - no matter, if operation was successful or not)

func func_print(text):
print(text)
```

the window will lose focus and gain it again shown in the output:
```
exit
enter
```

### Minimal reproduction project (MRP)

[trash-bug.zip](https://github.com/user-attachments/files/17874761/trash-bug.zip)

Contributor guide

Open the contributing guide

Research direction

Start with the OS.move_to_trash() entry point and the attached trash-bug.zip reproduction project. Run it on the tested Windows setup and observe the focus_entered/focus_exited output when the operation is called. Done means moving a file to trash, including the invalid-path case, no longer makes the application window lose and regain focus.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.