Skip to content
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

[X11] Don't re-set input focus if the given window already has it (fixes Godot stealing input focus on i3) #86671

Merged
merged 1 commit into from
Jan 18, 2024

Conversation

dsnopek
Copy link
Contributor

@dsnopek dsnopek commented Dec 31, 2023

Fixes #86442

Currently, DisplayServerX11 will set the input focus to a given window (via XSetInputFocus()) in a bunch of places. All this change does is checks to see if the given window already has input focus, and if so, skips setting input focus.

This fixes an issue I've been having in every version of Godot 4 with the i3 window manager when Godot launches the external editor (VS Code in my case), where input focus would visually seem to be on the external editor, but Godot would continue to receive all my key presses. (See in the issue linked above for a more detailed explanation.)

I don't know X11 very well, but what I think is happening, is Godot is re-setting the input focus to itself when it gets the mouse click to open the external editor, but that doesn't happen immediately, it happens sometime after VS Code has already gotten focus. So, shortly after VS Code gets focus, it gets yanked back to Godot.

In some ways, this is kind of the inverse of PR #86441, which some users of other alternative window managers say fixes similar problems for them (but not me).

@akien-mga
Copy link
Member

Tested briefly on KDE / X11, didn't spot any unexpected behavior.

@dsnopek dsnopek added the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label Jan 18, 2024
@dsnopek
Copy link
Contributor Author

dsnopek commented Jan 18, 2024

I've rebased this one now that PR #86441 is merged, and re-tested it: I still have the issue without this PR, and it's still fixed with this PR.

It would be sooooo amazing if this could maybe make it into 4.3-dev3?

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's give it a spin :)

@akien-mga akien-mga merged commit 1716388 into godotengine:master Jan 18, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@akien-mga
Copy link
Member

Cherry-picked for 4.2.2.

@akien-mga akien-mga removed the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label Mar 11, 2024
@dsnopek dsnopek deleted the i3-focus-steal branch July 22, 2024 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants