-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Godot Editor and Project Manager steals focus on a window manager on Linux. #68305
Comments
I can also confirm this bug for Fluxbox on Debian 10. LXDE on Debian 11 works as expected. The fastest way to reproduce it is opening Godot with an empty project list. The project list window and the "open assets store" popup fight for the focus. |
Some other impacts of this issue:
In both cases, clicking the window that should have focus does not allow it to regain input focus as the window manager already considers the window to be focused. Instead you have to click another window so that it loses focus and then click back to the target window so it regains full focus (including input focus). |
After studying the problem a little bit, it seems like the The problem doesn't happen on KDE Plasma with the Bismuth addon, so that's my temporary solution for now. I'm trying to do a fix for it but unsure how to produce a test for this or if it's even necessary to have this piece of code in here, since the If we can't just remove it, maybe we can fix this by making sure one of the parent windows doesn't already have the focus before executing the function? |
I want to report the issue still happens in the RC1 for 4.0. I will keep track of this issue and check again in 4.1. I will stick to the latest stable (3.x) for now and if I need 4.x for a project I already checked the next patch fixes the issue for me: diff --git a/platform/linuxbsd/x11/display_server_x11.cpp b/platform/linuxbsd/x11/display_server_x11.cpp
index 525c62fbf2..0f741ef035 100644
--- a/platform/linuxbsd/x11/display_server_x11.cpp
+++ b/platform/linuxbsd/x11/display_server_x11.cpp
@@ -4215,7 +4215,7 @@ void DisplayServerX11::process_events() {
// RevertToPointerRoot is used to make sure we don't lose all focus in case
// a subwindow and its parent are both destroyed.
if ((xwa.map_state == IsViewable) && !wd.no_focus && !wd.is_popup) {
- XSetInputFocus(x11_display, wd.x11_window, RevertToPointerRoot, CurrentTime);
+ //XSetInputFocus(x11_display, wd.x11_window, RevertToPointerRoot, CurrentTime);
}
_window_changed(&event); As @nargacu83 pointed out, the challenge for this is understanding whats that line trying to do exactly and why it was necessary in the first place. I worry removing it may produce a regression if we don't try at least the 5/6 most common WM for X11. |
Reporting that this bug is present on:
For me, this issue is a hard blocker for using Godot4 because even in single-window mode, the editor and the debugger fight for focus when running the game via F5, which is a core part of my workflow when prototyping in GDScript. Also, while the two windows are fighting for focus, they steal all input, so I can't even use an Currently using this shell script to test:
Commenting out the conditional in I don't know enough C++ to contribute any code, but I would be happy to help with regression testing if someone else submits a PR. Let me know if there is anything specific that I can help test. :) |
Seeing that @bruvzg is assigned, if you need further details on this, feel free to ask. I'm also available on Discord if you need to discuss it. If you want to get to an old commit when the majority of the design for the definition file is done, you are probably looking at 4396e98 .
You are also probably interested in an application called @reduz deserves a shout out for that implementation. It works very well, handles lots of edge cases and it looks like he was losing his mind in the process: |
Still breaks everything. I didn't open a new report for 4.1 |
Looks like a different bug. Godot 3+ was fine in my system (also X11+Fluxbox). Maybe they backported the changes from 4, but I don't think so. Are you experiencing the same behavior? The easiest way to reproduce this is opening the editor with a empty project list. |
I'm sorry, it's not about 3.5.2 (checked). My mistake. Tried: There were no problems a ~ week or two ago. But now I just can't create or open projects. Main window and dialog starts blinking. It hangs whole WM, until killall Godot.... |
So, if it kills all the thing, why is it there???
I mean 4.1.1 still has this issue.. |
Well, i may have an answer for that. If i understood correctly. It appears to handle an internal focus state. Godot will check if any window and it's parent should have the focus. The problem here, is this focus state is not in sync with the WM focus. |
Just wanted to leave my two cents as this issue makes godot nearly unusable for me as someone who is reliant on window managers to be able to use my computer without my hands exploding in a comical puff of dust. If the presence of lines 3855 ~ 3857 in Idk, definitely a small-scope take from me that likely won't work in a project as big as Godot. Just really hope to see this fixed and to not have to deal with using a bespoke fork on all my linux machines. |
This is fine for any of us to do in our local builds. And it will certainly be one of the steps tried by whoever tackles the issue. But Godot is used by lots of people and using them as guinea pigs for debugging is not good engineering and it will hurt the project. I automated the creation of the fork a long time ago and I suggest you do the same. This doesn't affects many users and looks insanely complex. If they ever fix it they will be doing us a favor. With only the benefit of one of them training on X11. And X11 is dying (sadly, because my hands also explode if my carefully keyboard-based crafted environment changes). There is also the option of the bounty... But I guess it will be also difficult to find someone for it. |
Just in case anyone finds it useful, I created a fork that includes the workaround patch so that affected users that aren't comfortable with editing the C++ code can start using Godot 4 without maintaining a patched version of the engine themselves. https://github.com/GrammAcc/godot4-workaround-68305 It's in the README on the fork, but just for the sake of CYA, I'll reiterate it here: This fork is not intended for use in production. Since we don't know what kind of regressions the workaround might introduce, you should NOT export any projects to production using this fork. I can't contribute much to the engine itself, but hopefully this is helpful. :) |
Sorry for ghosting this thread for a while. Been busy with work and internships. :) @nargacu83 I'd be willing to take over on this one once I'm finished with the other issue I'm working on, but I'm not sure when that will be. I don't have a lot of free time these days, so I pretty much only work on open source stuff on Saturdays. It might be a couple more weeks before I can work on this one. Maybe even longer. :/
I'm not sure what combination of events would result in that condition. I simply applied the workaround identified in this thread, so that other people wouldn't have to themselves. 😅 I'm also a C++ newbie and not very familiar with X11 either. That being said, I broke out the pickaxe and found the PR that adds the block in question: #41456, but it is from long before this issue was opened. I noticed these problems on my machine prior to this issue as well, but I wasn't using Godot4 until late 2022, so I'm not sure when this problem was actually introduced. When I get the chance, I will try building from the commit in that PR to see if this problem was introduced at that time, but I doubt it since it wasn't reported until recently. In any case, this should at least give us an idea of whether the root cause is the ConfigureNotify handler or if there is a deeper problem with the display server implementation on X11 causing events to get mishandled. :) |
Well I tried to test this out on 2b49cb0 from #41456, but the third party libs in that commit aren't compiling on my machine. 🙃 The other issue I was working on got taken care of by another contributor, so I can start digging deeper into this one. It looks like there was quite a bit of discussion in #74378 regarding tiling WMs, and it seems the common ground between the two issues is that Godot steals focus when windows are resized or moved, even if window focus doesn't actually change. That would explain why commenting out the The input focus section of the Xlib docs seems promising, but I don't have the time or energy to digest it right now. One possibility for a root cause of all these issues that comes to mind is that the current implementation is actually correct as far as what should happen during each event, but due to the asynchronous nature of the client-server communication between X and each different UI application on the desktop, some events are being handled out of order resulting in the same kind of non-deterministic behavior that we get when we have race conditions in concurrent code. I will look into the way that X handles these different events, but if there is a sequence of actions that need to happen before an I will try to dig into this some more when I have more time, but it seems like an actual fix and not just a workaround will require digging deeper into how all of the events are being handled. |
Updated my workaround fork to latest stable version 4.1.3. It still works like the previous versions of the workaround on my machine. :) I'm also reading up on the X Window System since I don't really understand how all the events are used or how they fit together yet. Will report back here if I figure out anything about the Godot implementation that might be useful. |
I have had very little time to work on Godot lately, and I've been preoccupied with a separate issue that was related to a PR I submitted previously, so I have not been able to look into this any more since my last comment at the beginning of November. I'm starting to wonder if we should just submit the workaround as a PR and go from there since no one has reported any significant regressions with it and no one seems to have the time to really figure out the problem with X11 either? It doesn't solve the workspace issues mentioned in #68305 (comment), but without it, I can't even open Godot on my machine since any popup will cause a total lock of my machine and I have to force shutdown to fix it. I'm not sure if the bug is that severe on anyone else's setup, but considering the severity on some machines, I think it's probably worth it to just submit the workaround as a PR if we don't have the resources to research a full fix. I do worry that maybe there could be a regression on some other setup and we haven't heard about it since users on other setups aren't affected by the bug in the first place, but in the worst case, the PR reviewer will just reject the PR and we'll be back to scrounging for help with this bug. @nargacu83 do you want to submit a PR for this since you originally identified the workaround of removing the |
I will reply to this as I replied to: #68305 (comment) ITT We should not use neither the final Godot users nor the internal time of the reviewers to validate a workaround that we did not validated/understood ourselves. I deal with this using a different WM when I work with Godot. Obviously is not ideal, but is not a "blocker" issue for that many systems if you add an alternative option to your DM/startx to launch LXDE (or any other working WM). |
I was not trying to suggest that we use the users or maintainers to validate the workaround. I was under the assumption that all of the affected users in this thread are using this workaround, and none of them have reported any regressions for several months. I would consider this to be validation of the workaround in as much as I would consider a thorough fix validated. Ultimately, any fix we provide will need to be tested on other systems/setups to ensure it doesn't cause regressions. I completely agree with you about using users/maintainers for validation, and I really want more testing before submitting something, but no one here has the time to really dig into this, and I'm not comfortable with the assumption that this critical bug is completely isolated from the rest of the system. This is a bug that causes total system lock on X11 with certain configurations. This might not affect users of Godot, but what about users of Godot games? We have to keep in mind that Godot games are the editor with some extra code included, and since it's a platform bug and not specifically an editor UI bug, it's entirely possible that someone loading up a popular title built with Godot4 on the Steam Deck or a Linux desktop could encounter the same bug when the game pops up a notification window about a Patreon or something. This is a very contrived example, but I'm just trying to articulate my concerns with the current situation. I feel like sitting on this when we have a potential fix for the most critical portion of this bug is irresponsible, and I just don't have the time to properly investigate a full fix. You make a completely valid point about not wasting the maintainers time though. This is a massive project, and they are very busy. I will ask about this in the Godot Contributors Chat to see what the experienced/core contributors think we should do. I'll report back here once I get an answer. :) |
I agree, we should not do a PR about this unless we found and tested a real solution and not just a partial workaround on this issue. I'm sure we will find a suitable solution in the future. I will try to allocate some time to do a proper test on this issue to locate where and why the fix is needed. In the meantime my personal workaround has been to use a Wayland compositor or DE which the issue is isolated in XWayland (some annoyances with color picker or nodes selection modal for example). |
It will be really nice to hear their feedback/ETA on this problem. Thanks! Just to clarify, this only affects some X11 users using a particular set of WMs (in my case, Fluxbox). The issue disappears when using a different WM so it is completely plausible that Godot is doing a proper handling of X11 notifications and the WMs themselves have the problem. There is not reason nor evidence to suspect that Steam Deck or Linux standard users will find this problem affecting them. This will happen only to such users that at the same time are using one of the affected WMs, requiring some knowledge of customization. Also, in my case, I had problems with the initial versions workaround (I don't remember the particulars right now) and I switched my WM to remain in the official Godot release build. I haven't tried the new version of the workaround but it looked more promising that the previous one (keeping the state of the window certainly looks safer than just commenting some lines). |
I always was suspicious about something (either Godot or the WM) considering X11 notifications (or a wrong subset of them) as focus grab intents. I didn't have the time to confirm this but peeking around using xev gave me that impression. Were you able to pinpoint this a little more? What do you think about the "every notification is a grab" theory? |
I got a response in the Contributors Chat from @Riteo, a contributor working on the Wayland implementation:
I can submit a PR with the workaround after work today. I think I will just submit the original workaround that simply removes the XSetInputFocus in ConfigureNotify since @unlessgames had mentioned some odd focus behavior with the WIP solution @nargacu83 has going. Even if it gets merged, this is just a stop-gap, so eventually we will need a proper fix, and there is also #74378 to consider as well. One thing that will help with peace of mind is if the affected users who are running other DEs to workaround this issue can test out the version with the workaround included in Godot on the DEs that they have already confirmed work without it. That should give us at least some regression coverage, and if it does break on those DEs, we would then actually know that there is a problem with this hack. Let me know if anyone has any questions about the PR. I don't think it should have much affect on work we do on this issue going forward though. :) |
I submitted a workaround PR #86101. Since this is a low priority issue for the maintainers, it probably won't be reviewed right away (especially with 4.2.1 in RC rn). If a breakthrough is made on this issue in the meantime and it looks like we'll have a full fix soon, I can convert it to a draft to prevent complications. Feel free to @-mention me for help with testing. I'm too busy to put a lot of time into development these days, but I can at least compile and run the engine to see if a patch fixes this issue. :) |
Hey everyone, the maintainers gave some feedback on the workaround PR. In particular: #86101 (comment) If anyone here who is affected by this bug is able to test the commit in the PR db4a662 on unaffected DEs/WMs, please comment if you see any issues or if the problem appears on other setups. It looks like the maintainers have already confirmed it works on i3 and KDE Plasma, so other non-tiling WMs/DEs would be good to test if possible. I'm going to try to get a few other DEs/WMs installed and tested after work this week, but any additional testing/confirmation is greatly appreciated. :) Thanks! |
Thanks for still caring about this issue @GrammAcc Your deletions fix the consistent focus stealing which I reported on with #80170 that seemed to happen under any circumstance in i3. However the following issue can still be reproduced: Here is a video, the first part shows stepping the focus through windows via keyboard working as expected. godot_focus_i3.mp4As you can see the left terminal shows the X11 debug logs and this particular issue might be related to incorrect handling of Another thing to point out is that triggering of the
This isn't and shouldn't be the case. Currently there is |
Yeah, the workaround PR only fixes the most critical problem which is total system lockup on certain specific configurations (mine lol) and is really just a stop-gap to keep that from happening in exported games, so I don't expect it to really fix most of the focus issues we're dealing with between this issue and #74378. This is super helpful info for actually fixing the real problem though. Thanks! Unfortunately, as Riteo mentioned in the contributor's chat, it looks like the X11 backend is pretty hacked together, and based on the issues referenced by maintainers in the workaround PR discussion, I think the focus behavior has gone through several iterations and will probably require a pretty significant rework of the various event handlers to solve these problems without introducing others. I still haven't had time to really read up on X11, and what I have read up on is very difficult to make sense of. It doesn't Here's the API documentation for the MapNotify event:
I still haven't figured out what an event is in X11. 😅 I think the terms unmapped and mapped mean not created/spawned and created/spawned, so I would think that MapNotify shouldn't be firing on focus swap, only when the window is opened initially. I may be wrong about that though. I wish the X11 docs had a glossary. :) |
@GrammAcc FTR, "mapped" should mean "shown" as in "I created this window object but still haven't shown/mapped it on the screen". |
I had this issue using arch and fluxbox. Kept me from switching to Godot 4 for some time, since it's hard to find what exactly causes the issue if you have no clue. I first suspected issues within my window manager. Even when I narrowed things down to an issue with godot, this PR wasn't easy to find. |
FYI for anyone who is watching this issue. The workaround that I was adding to releases in my fork has been merged into master, so anyone who is using that fork should switch back to the official binaries on the next release. I'll probably delete the fork after the next official release as long as my other open PRs are merged or closed by then. There isn't really any reason to maintain it at this point, and I've fallen behind on patching the stable releases as well. :) Also, it would be great if anyone who is affected by this issue could build from source on the latest master to see how things go. The workaround that was merged in #86101 doesn't fully resolve this issue, but it fixes the system lockup on my setup, and other users have reported some improvements with it previously. A couple other PRs related to focus issues on X11 (#86441 #86671) have been merged since then though, so any feedback on the current build would be appreciated. Thanks! |
With current v4.3 dev5 the focus issue still happens with the find dialog on linux |
When you say "find dialog", you are referring to an OS dialog like an app picker, right? Sorry if this is common terminology, I use a bespoke WM setup, so I don't have most standard linux UI features. 🙃 I ask because there was another issue of Godot windows and sub-windows fighting for focus amongst themselves that should be fixed in latest dev, so I wanted to make sure it wasn't a problem with that fix. If you can confirm your distro and WM/DE, that would be helpful info for anyone working on this as well. :) |
Right! Happy to clarify.
Using Arch with awesomewm as my window manager.
And I'm speaking of the "find in files" dialog that is part of Godot
itself, which pops up via ctrl+shift+f if my memory serves me correctly.
…On Wed, 20 Mar 2024, 14.49 Dalton Lang, ***@***.***> wrote:
With current v4.3 dev5 the focus issue still happens with the find dialog
on linux
When you say "find dialog", you are referring to an OS dialog like an app
picker, right? Sorry if this is common terminology, I use a bespoke WM
setup, so I don't have most standard linux UI features. 🙃
I ask because there was another issue of Godot windows and sub-windows
fighting for focus amongst themselves that should be fixed in latest dev,
so I wanted to make sure it wasn't a problem with that fix.
If you can confirm your distro and WM/DE, that would be helpful info for
anyone working on this as well. :)
—
Reply to this email directly, view it on GitHub
<#68305 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKEEGBSUNYIHZGJCQZ4ADTYZGAV5AVCNFSM6AAAAAARYDCY2CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMBZGQ4TCNJRGY>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
@speakk Thanks for clarifying! I normally use nvim as an external editor, so I actually didn't know that this feature existed. 😅 It might be something specific to tiling window managers. There have been several other focus problems reported on tiling WMs (mainly i3). Some of which have been addressed in recent PRs. I don't think there are any dedicated issues for focus problems on tiling WMs open rn, but #74378 might be of interest. I think a lot of different focus issues have become tangled up in this issue and #74378, so it's kind of hard to tell what has been fixed so far. :) |
I realized that because users still have to build from source if they were using my fork, there isn't any point in keeping it around until the binaries are released, so I went ahead and deleted it. If anyone was still using that fork, you should be fine to simply build from master now. :) |
They can use the 4.3-dev5, the partial fix is apparently included in it. ;) |
Note that the Find in Files lose focus bug is a specific regression between v4.2.1 and v4.2.2 which has already been bisected, see #88847 |
This is still an issue in 4.3.stable. Select a script and use a global shortcut key to open a terminal. The keyboard focus will be on Godot script instead of the newly opened window which has asked for focus briefly. |
Bugsquad note: This issue has been confirmed several times already. No need to confirm it further.
Godot version
v4.0.beta4.official [e675154] (any 4.0 version)
System information
Arch Linux with kernel 6.0.7-arch1-1 on AwesomeWM, X11
Issue description
The project manager and the editor steals the focus on Window Managers on Linux with X11 when opening other programs or when changing layouts. It doesn't happen on Godot 3.x.
I tested it on AwesomeWM, Hypr, LeftWM and DWM. Only LeftWM and DWM doesn't have the issue but i'm pretty sure they don't "implement" ConfigureNotify but i don't know much in the display server area.
However i managed to "fix" the issue by commenting out this if statement.
godot/platform/linuxbsd/x11/display_server_x11.cpp
Lines 3855 to 3857 in 6882890
Steps to reproduce
awful.layout.suit.tile
layoutMinimal reproduction project
You can use the default configuration of AwesomeWM.
No project needed.
The text was updated successfully, but these errors were encountered: