godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.34k stars 20.01k forks source link

Godot Editor Stealing Focus From Game #74587

Open Orgull1972 opened 1 year ago

Orgull1972 commented 1 year ago

Godot version

4.0 Stable

System information

Windows 10

Issue description

After a game starts, the Godot Editor steals focus, sending keypresses to the editor, until I either Alt-Tab out and back into the game, or click with the mouse, anywhere in the window. (Fullscreen and Exclusive modes only)

Steps to reproduce

This happens in ALL my projects, even just now an empty test project I made, added a Character3D node, with the default movement controls, and the Character3D would not move until after I alt-Tabbed out and back in, OR until after I clicked somewhere in the window. All the keypresses I made before clicking appeared in the script editor.

I put print statements in all my input handlers in all my projects and confirmed that no keyboard inputs are ever registered until after an alt-tab or a click.

IMPORTANT: This issue does not happen with any other version of Godot, only 4.0 Stable. Input works perfectly in all previous versions, so I'm assuming it's not a hardware issue. This issue ONLY happens in Fullscreen and Exclusive Fullscreen modes and does not occur in Windowed modes. This issue happens in both Forward+ and Compatibilty mode.

Minimal reproduction project

project - Copy.zip

My current practice project (Trying out things that are different in Godot 4 for the first time, like CharacterBody3D)

akien-mga commented 1 year ago

Assuming this is platform-specific as windowing issues often are (and I don't reproduce on Linux). CC @bruvzg

venilark commented 1 year ago

I am pretty sure the error only happens if you disable Window>Size>Resizable, at least with Fullscreen/exclusive fullscreen, didn't test with the other modes. But even in that case, focus is lost for half a second (the times it decides to lose focus, it doesn't happen all the time).

stuartfulton commented 1 year ago

I had this problem consistently in Windows, and can confirm that re-enabling display/window/size/resizable fixes the issue.

cj-33 commented 1 year ago

Seeing a similar issue in Arch Linux with LXDE and the Godot IDE itself. alt-tabing from Godot IDE window will randomly not work and instead return focus to the Godot IDE instead of the target application window. This can be seen happening at 15 seconds and 25 seconds in the attached video. (Note, I first noticed this in xmonad which I normally use but I reproduced it in LXDE since that's less obscure). I've never seen this happen with any Godot 3.x versions (including 3.5.1) nor have I ever seen this with any other applications. It happens with any kind of application window (terminal, web browser,...)

VERSIONS: Godot 4.0 xorg-server 21.1.7-1 libx11 1.8.4-1 lxde-common 0.99.2-3 linux 6.2.5.arch1-1 nvidia-open 525.89.02-10
xmonad 0.17.1-86 (not used in video demo, ignore this if not familiar)

https://user-images.githubusercontent.com/4165806/224769810-4984804c-404b-4db2-8950-3d3b3becfe77.mp4

tribly commented 1 year ago

I have the same problem but with i3wm. Having godot on one workspace alone, and trying to switch to another workspace. But only when trying to use the hotkeys (win+$workspacenumber), not when clicking the workspaces in polybar.

Also, when opening another program on the same workspace: godot.webm

Versions: Godot 4.0 xorg-server 21.1.7-1 libx11 1.8.4-1 i3-wm 4.22-3 linux 6.2.2.arch1-1 nvidia 525.89.02-6

stevenre3d commented 1 year ago

Seeing this on Qtile as well. I have firefox fullscreen on one monitor and godot fullscreen on a 2nd monitor. If I click into the address bar on ff and start typing, everything goes to godot. If I toggle floating on the ff window and then try the same thing, it works normally again.

ator-dev commented 1 year ago

Same problem as @tribly , and has been happening for a long time in 4.x. Switching workspaces in Regolith (Ubuntu with out-of-the-box i3) is fine, but trying to switch to a tiled adjacent window is often impossible and requires actually creating a window specifically so that I can switch to it from the other direction. It seems to aggressively demand focus whenever it is even slightly resized by the window manager.

https://user-images.githubusercontent.com/66553618/234693156-d693335c-2126-4894-a98d-1ad8c0f8f7dc.mp4

All of the things I do in that capture - resizing various tiled windows, moving to a different 'tab' which causes borders to no longer be drawn around Godot - cause it to receive a resize signal by the wm. And that seems to be what tells it to aggressively pull back focus, to the point of making it impossible for me to switch to other windows in some cases.

Edit: Nevermind, just noticed the much-confirmed issue for this. I hope this can be sorted out at some point, unfortunately I don't have anywhere near the time to test it out in multiple wms :confused:

venilark commented 8 months ago

just happened to me right now, I was using WASD to move and nothing happened, then I left clicked and everything worked, went back to the editor and had "wadsdsdsdawwswdasw" written there sometimes the keyboard works but not the mouse until I left click, maybe this is a different issue 4.1.3, Windows 10

bkesecker commented 7 months ago

Echoing @stuartfulton Grabbing focus once did not seem to help, nor repeatedly. Behavior outside the editor also seemed affected. Using version 4.2.

gregkrsak commented 7 months ago

Godot 4.2, Windows 10, Same issue. I have to left-click on my game first.

Cequallium commented 4 months ago

i am experiencing the same issue (focus stealing from all apps) Versions: Godot 4.2.1 Plasma 6.0.3 Wayland linux 6.6.26

darkhog commented 3 months ago

Apparently it happens when "Resizeable" is unchecked in the project settings. #74619 has more info about it as well as a workaround. By the way, still an issue on 4.2.2.

Vitorgus commented 2 months ago

Same issue, but unlike #74619, my project had display/window/size/resizable checked. What worked for me was unckecking display/window/size/always_on_top.

System information: Godot v4.2.2.stable - Windows 10.0.22631 - Vulkan (Forward+) - dedicated NVIDIA GeForce MX130 (NVIDIA; 31.0.15.5222) - Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz (8 Threads)

Sebauxs commented 4 weeks ago

Same issue here, I'm getting this logs:

platform/windows/display_server_windows.cpp:2572 - Parameter "hicon" is null.
  Failed to create Windows OS window.
  Failed to create sub window.
  scene/main/window.cpp:592 - Condition "window_id == DisplayServer::INVALID_WINDOW_ID" is true.
  platform/windows/display_server_windows.cpp:1313 - Condition "!windows.has(p_window)" is true. Returning: -1
  scene/main/window.cpp:592 - Condition "window_id == DisplayServer::INVALID_WINDOW_ID" is true.
  platform/windows/display_server_windows.cpp:1313 - Condition "!windows.has(p_window)" is true. Returning: -1
Gr0minet commented 4 weeks ago

Same problem. I have display/window/size/resizable checked and display/window/size/always_on_top disabled (both default).

System information:

Linux 6.1.0-23-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.99-1 (2024-07-15) x86_64 GNU/Linux
Intel Core i7-8565U

Godot Engine v4.3.rc1.official.e343dbbcc - https://godotengine.org
Vulkan 1.3.230 - Forward+ - Using Device #0: Intel - Intel(R) UHD Graphics 620 (WHL GT2)