godotengine / godot-vscode-plugin

Godot development tools for VSCode
MIT License
1.53k stars 151 forks source link

Give focus to game on run #692

Open DanielPri opened 1 month ago

DanielPri commented 1 month ago

Godot version

4.2.2.stable.official

VS Code version

1.92.0

Godot Tools VS Code extension version

2.1.0

System information

Windows 11

Problem statement

When running the game, focus is still on VS Code editor, requiring an Alt-tab to switch focus to the game. Is it possible to optionally give focus to the game automatically? While a very small QoL feature, it would be very appreciated! I could not find this setting in the command line documentation for godot, and yet when running directly from godot engine focus is given to the game.

Proposed solution

Optionally give focus to the game automatically upon run/run with debug. Perhaps by using a powershell command?

DaelonSuzuka commented 1 month ago

When I hit F5 to launch the game, it opens on top of VSCode and is focused, UNLESS I interact with VSCode during the brief delay while the game is launching, in which case I get the behavior you're describing.

sangold commented 1 month ago

It is weird, the run window used to behave like you described @DaelonSuzuka but I too now have the same issue. When hitting F5, the window does not pop into focus and stay behind. I tried to find what changed but couldn't find any changes on neither the project settings nor the vscode settings. The launch config looks standard:

"configurations": [
        {
            "name": "GDScript: Launch Project",
            "type": "godot",
            "request": "launch",
            "project": "${workspaceFolder}",
            "debug_collisions": false,
            "debug_paths": false,
            "debug_navigation": false,
            "additional_options": ""
        }
    ]

I run into the issue on both 4.2.2 and I just tried 4.3 to see and still the same. TBH, not sure how much the plugin can solve this.

DanielPri commented 1 month ago

For clarity, I do not interact with VSCode during the brief delay as it launches. (tried again a few more times to be sure) Tried seeing if it behaves differently if running through F5, or by using mouse to navigate to the Run->Start Debugging option, and still the game launches without focus. Although as sangold mentionned, there might not be a solution plugin-side.