Repository: godotengine/godot (language: cpp)

Issue:
Debugging embedded game does not refocus on continue
### Tested versions

Godot v4.4.dev (99a8ab795)

### System information

Godot v4.4.dev (99a8ab795) - Windows 11 (build 26100) - Multi-window, 1 monitor - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3070 Laptop GPU (NVIDIA; 32.0.15.6603) - AMD Ryzen 7 5800H with Radeon Graphics (16 threads)

### Issue description

When the game is embedded without the floating window, after hitting a breakpoint in the script editor, when I pressed Continue, the game tab is not refocused and Godot enters a wierd state where the editor is not focused, the game is probably focused but not visible.

### Steps to reproduce

- In the Game Workspace, enabled Embed and disable Floating Window
- Attach a script and add a breakpoint anywhere
- Start the game
- Hit the breakpoint
- Press Continue

https://github.com/user-attachments/assets/fe304f67-773d-4948-9ec7-790e06b28db6


### Minimal reproduction project (MRP)

[test-godot-focus-debugging.zip](https://github.com/user-attachments/files/18269775/test-godot-focus-debugging.zip)



Discussion / hints:

Fix patch:
diff --git a/editor/plugins/embedded_process.cpp b/editor/plugins/embedded_process.cpp
index 9d14e702be41..03c2f2067e9c 100644
--- a/editor/plugins/embedded_process.cpp
+++ b/editor/plugins/embedded_process.cpp
@@ -296,6 +296,7 @@ void EmbeddedProcess::_check_focused_process_id() {
 		focused_process_id = process_id;
 		if (focused_process_id == current_process_id) {
 			// The embedded process got the focus.
+			emit_signal(SNAME("embedded_process_focused"));
 			if (has_focus()) {
 				// Redraw to updated the focus style.
 				queue_redraw();
@@ -312,6 +313,7 @@ void EmbeddedProcess::_bind_methods() {
 	ADD_SIGNAL(MethodInfo("embedding_completed"));
 	ADD_SIGNAL(MethodInfo("embedding_failed"));
 	ADD_SIGNAL(MethodInfo("embedded_process_updated"));
+	ADD_SIGNAL(MethodInfo("embedded_process_focused"));
 }
 
 EmbeddedProcess::EmbeddedProcess() {
diff --git a/editor/plugins/game_view_plugin.cpp b/editor/plugins/game_view_plugin.cpp
index f7e58258d425..d611f0a773cf 100644
--- a/editor/plugins/game_view_plugin.cpp
+++ b/editor/plugins/game_view_plugin.cpp
@@ -260,6 +260,12 @@ void GameView::_embedded_process_updated() {
 	game_size_label->set_text(vformat("%dx%d", game_rect.size.x, game_rect.size.y));
 }
 
+void GameView::_embedded_process_focused() {
+	if (embed_on_play && !window_wrapper->get_window_enabled()) {
+		EditorNode::get_singleton()->get_editor_main_screen()->select(EditorMainScreen::EDITOR_GAME);
+	}
+}
+
 void GameView::_project_settings_changed() {
 	// Update the window size and aspect ratio.
 	_update_embed_window_size();
@@ -730,6 +736,7 @@ GameView::GameView(Ref<GameViewDebugger> p_debugger, WindowWrapper *p_wrapper) {
 	embedded_process->connect("embedding_failed", callable_mp(this, &GameView::_embedding_failed));
 	embedded_process->connect("embedding_completed", callable_mp(this, &GameView::_embedding_completed));
 	embedded_process->connect("embedded_process_updated", callable_mp(this, &GameView::_embedded_process_updated));
+	embedded_process->connect("embedded_process_focused", callable_mp(this, &GameView::_embedded_process_focused));
 	embedded_process->set_custom_minimum_size(Size2i(100, 100));
 
 	state_label = memnew(Label());
diff --git a/editor/plugins/game_view_plugin.h b/editor/plugins/game_view_plugin.h
index 6568f07b746c..64d679657c33 100644
--- a/editor/plugins/game_view_plugin.h
+++ b/editor/plugins/game_view_plugin.h
@@ -143,6 +143,7 @@ class GameView : public VBoxContainer {
 	void _embedding_completed();
 	void _embedding_failed();
 	void _embedded_process_updated();
+	void _embedded_process_focused();
 	void _project_settings_changed();
 
 	void _update_ui();


Test patch: