Repository: godotengine/godot (language: cpp)

Issue:
Embedded Game window stops rendering when editing other nodes in the editor
### Tested versions

Differences between Godot 4.3 and the new embedded game window feature in Godot 4.4

### System information

Godot v4.4.beta1 - Ubuntu 22.04.5 LTS 22.04 on X11 - X11 display driver, Multi-window, 2 monitors - OpenGL 3 (Compatibility) - AMD Radeon RX 6600 (navi23, LLVM 15.0.7, DRM 3.57, 6.8.0-51-generic) - AMD Ryzen 7 5700X 8-Core Processor (16 threads)

### Issue description

Godot4.3 works great already for gaming while editing it at the same time. I run the game, and then 'windows key + tab' over to the editor to make changes and see it in real time. I was curious if the embedded game window would make this even better somehow but certain what the added functionality would be.

In Godot 4.4 beta, when running the game, it pops up in the new window, on my second screen. If i tab over to the editor to make a change to any nodes, it detects i'm now looking at a specific object , or script, and not the game anymore and so stops rendering the game in the second window. This is very  frustrating. I'd normally pop over to the editor to adjust a Directional Light, or Environment Fog, and see it in real time in the game, but the embeded view stops rendering so now i have to tweak, and then tab back, and tweak and tab back. And it's a lot more work to see changes in real time.

I can't seem to find a settting to have it 'always on' even when not on that tab, or revert back to a classic mode or something. 

EDIT:
![Image](https://github.com/user-attachments/assets/08b7dbd4-db63-4a47-9a39-aa313b38621f)

Aha! So these are the settings to go back to a classic mode. The wording on both is a little odd. Since Embed and Docked can have similar meanings and these two settings next to each other aren't clear because of it. I was going to close the ticket but instead i'll edit it to reflect the wording issue, and that when floating the game workspace, it should keep rendering even when editing other things. That's seems the whole reason to make it a floating window no?

So wording wise:

Enabling a bool for "_Make Game Floating on next play_" is the most curious to me. I'd think this wording better:
"_Dock Game Window_"  (Enable the bool to dock, and disable to make floating, inverse of what is current here)

And the other setting "Embed Game on next play" add confusion since embed and dock have similar ideas. I was unsure what it meant since it sounds like docking/floating, the window and isn't clear it means it's going to actually enable or disabled in-editor game workspace.

Perhaps better wording there too:
"_Enable in-editor game workspace_" (disable to run externally)

### Steps to reproduce

I start any game running using the "embeded game on next play" and "make floating" settings enabled.
See it running on your second monitor
Tab back over to the editor.
See the game stop rendering the second you go to edit anything.
Click back to the game and see it come back.



### Minimal reproduction project (MRP)

Load a project.
Start the game
Move the game to a second scree or even just split your screen into section.

Click on any node in the editor. the game stops rendering, swaps to 3D, Script, 2D etc, tabs, and you can't make realtime edits and see them in game.


Discussion / hints:
Thanks for reporting this issue.

Unfortunately, I'm unable to reproduce it on my computer running Ubuntu 23.10. I tested it on both Wayland and X11. With on or two monitors
Godot v4.4.beta1 - Ubuntu 23.10 23.10 on X11 - X11 display driver, Multi-window, 2 monitors - OpenGL 3 (Compatibility) - Mesa Intel(R) UHD Graphics 630 (CFL GT2) - Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz (12 threads)

If I understand correctly, on your computer, the floating game window never re-renders when the editor is focused?

[[Link to attachment]](https://github.com/user-attachments/assets/9ab93a9c-8010-45c2-a99c-ab5f1e95a765)

Could you provide us with more information, please?  
- Does this occur with a new empty project? If not, could you provide us with a minimal reproducible project (MRP)?
- Are you using Gnome or another Window Manager?
 
Thanks also for your suggestions regarding the wording; some adjustments are definitively needed.
Using Xorg, vanilla Kubuntu OS, nothing fancy or extra. The issue isn't that it stops updating the rendered output, it's that the output literally disappears. 

I created a fresh project, here is just a camera in a 3D space, in Compatibility mode, and this clip shows it on one monitor too, rather than a 2nd. (ignore the code, etc that was me just spining the camera earlier to ensure the rendered output was updating, but it was making me seasick so i stopped it. )

But the fact it just goes blank, and switches to the 3D editor tab is s why i wonder if this is purposeful/intentional? like, if this is how the game workspace is supposed to work?  That the second you click back to the editor it just stops showing the game... but in your clip it's working as I'd expect it to, so I'm not crazy i suppose.

![Image](https://github.com/user-attachments/assets/14fbc28e-ae01-44ae-b3ed-552873f80160)
Thanks for the info and the video. Very helpful. No, it should really not do that. If you check my video, the game is always visible even when the editor is focused. I'll look into it.

**Edit: I confirm that I can reproduce the issue on Kubuntu 22.04.5. I'm working on a solution.

Fix patch:
diff --git a/platform/linuxbsd/x11/display_server_x11.cpp b/platform/linuxbsd/x11/display_server_x11.cpp
index 51db84fde02b..95181a1c8177 100644
--- a/platform/linuxbsd/x11/display_server_x11.cpp
+++ b/platform/linuxbsd/x11/display_server_x11.cpp
@@ -6276,7 +6276,7 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, V
 			}
 		}
 
-		if (wd.is_popup || wd.no_focus || wd.embed_parent) {
+		if (wd.is_popup || wd.no_focus || (wd.embed_parent && !kde5_embed_workaround)) {
 			// Set Utility type to disable fade animations.
 			Atom type_atom = XInternAtom(x11_display, "_NET_WM_WINDOW_TYPE_UTILITY", False);
 			Atom wt_atom = XInternAtom(x11_display, "_NET_WM_WINDOW_TYPE", False);
@@ -6422,6 +6422,7 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
 	KeyMappingX11::initialize();
 
 	xwayland = OS::get_singleton()->get_environment("XDG_SESSION_TYPE").to_lower() == "wayland";
+	kde5_embed_workaround = OS::get_singleton()->get_environment("XDG_CURRENT_DESKTOP").to_lower() == "kde" && OS::get_singleton()->get_environment("KDE_SESSION_VERSION") == "5";
 
 	native_menu = memnew(NativeMenu);
 	context = p_context;
diff --git a/platform/linuxbsd/x11/display_server_x11.h b/platform/linuxbsd/x11/display_server_x11.h
index 166b2cb57b5c..edd70d454da3 100644
--- a/platform/linuxbsd/x11/display_server_x11.h
+++ b/platform/linuxbsd/x11/display_server_x11.h
@@ -338,6 +338,7 @@ class DisplayServerX11 : public DisplayServer {
 	bool xinerama_ext_ok = true;
 	bool xshaped_ext_ok = true;
 	bool xwayland = false;
+	bool kde5_embed_workaround = false; // Workaround embedded game visibility on KDE 5 (GH-102043).
 
 	struct Property {
 		unsigned char *data;


Test patch: