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

Text editor steals focus from "Find in Files" dialog #88847

Closed
ghmart opened this issue Feb 26, 2024 · 9 comments · Fixed by #93682
Closed

Text editor steals focus from "Find in Files" dialog #88847

ghmart opened this issue Feb 26, 2024 · 9 comments · Fixed by #93682

Comments

@ghmart
Copy link

ghmart commented Feb 26, 2024

Tested versions

  • Reproducible in 4.3-dev3.
  • Not reproducible in 4.2.1-stable.

System information

Godot v4.3.dev3 - Debian GNU/Linux 11 (bullseye) 11 - X11 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3060 Ti () - 11th Gen Intel(R) Core(TM) i5-11600K @ 3.90GHz (12 Threads)

Issue description

Text editor steals focus when nothing is selected before invoking from "Find in Files" dialog.

Steps to reproduce

  1. Open any script. Don't select anything.
  2. Hit "Control + Shift + F" shortcut.

My attempt to fix

Tried to investigate "editor/find_in_files.cpp" ("FindInFilesDialog::_notification") and found that if replace
callable_mp((Control *)_search_text_line_edit, &Control::grab_focus).call_deferred();
with
_search_text_line_edit->grab_focus();
the problem is gone.

Not sure about "Doesn't work more than once if not deferred..." comment. It works normally subsequently (at least on my Linux with v.4.3-dev3).

Minimal reproduction project (MRP)

N/A

@pancelor
Copy link
Contributor

pancelor commented Feb 26, 2024

I also have this issue in 4.3-dev3 -- I was about to report it myself

My specs:

Version that's bugged: (ctrl-shift-f isn't usable without a mouse click to refocus the popup)

Godot v4.3.dev3 - Manjaro Linux #1 SMP PREEMPT Tue Nov 28 19:17:55 UTC 2023 - X11 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 750 Ti (nvidia; 545.29.06) - AMD FX(tm)-8350 Eight-Core Processor (8 Threads)

Version without the bug:

Godot v4.1.3.stable unknown - Manjaro Linux #1 SMP PREEMPT Tue Nov 28 19:17:55 UTC 2023 - X11 - Vulkan (Compatibility) - NVIDIA GeForce GTX 750 Ti (nvidia; 545.29.06) - AMD FX(tm)-8350 Eight-Core Processor (8 Threads)

@Sauermann
Copy link
Contributor

Bisected to 40d69c2 #86441
CC @Mequam @dsnopek

@akien-mga
Copy link
Member

Tried to investigate "editor/find_in_files.cpp" ("FindInFilesDialog::_notification") and found that if replace
callable_mp((Control *)_search_text_line_edit, &Control::grab_focus).call_deferred();
with
_search_text_line_edit->grab_focus();
the problem is gone.

Tested and this doesn't seem to work in current master.

CC @bruvzg @KoBeWi - maybe we can improve the Find in Files focus handling logic to make it less dependent on the timing of events.

@KoBeWi
Copy link
Member

KoBeWi commented Jun 18, 2024

Well call deferred is usually a way to fix such issues, because you make something happen last (in most cases). It would be nice to know what causes the focus steal. I can't reproduce it on Windows (tried single window mode, as it can't even happen with multiple windows).

@akien-mga
Copy link
Member

(tried single window mode, as it can't even happen with multiple windows).

For me on Linux (Fedora 40, KDE Plasma on Wayland, X11 DisplayDriver) the issue is only reproducible with multiple windows actually, and not reproducible in single window mode.

@KoBeWi
Copy link
Member

KoBeWi commented Jun 18, 2024

Huh I tested with multiple windows and seems like you can focus the editor, it just doesn't accept input.
Still can't reproduce the bug though.

@dsnopek
Copy link
Contributor

dsnopek commented Jun 27, 2024

This has been a little tricky for me to reproduce. It's not reproducible on my system (Ubuntu 22.04) with i3 (my usual environment) or GNOME. I used multiple window mode in both cases, and tried both Forward+ and Compatibility (above, someone said it happened for them only on Forward+ and not Compatibility).

However, I just setup a Fedora 40 VM in VirtualBox, and I am able to reproduce the issue there! (using Compatibility, since getting Vulkan running in VirtualBox is a pain)

Strangely, that is also GNOME, however, it looks like it's running on Wayland and so using xwayland. I wonder if that's the difference? On my host machine, I'm using real X11 in order to take advantage of the proprietary nvidia drivers.

It'd be great if other folks who are experiencing this issue could share:

  1. The name of their window manager or desktop environment?
  2. Whether or not you're using real X11 or xwayland?

In any case, I'll experiment with some changes to the code that was committed in PR #86441 to see if I can find a workaround.

@akien-mga
Copy link
Member

I reproduce the issue on Fedora 40 KDE Plasma/KWin on Wayland myself, so using XWayland. I can test tomorrow if it's indeed not reproducible on the same system with KDE X11.

@dsnopek
Copy link
Contributor

dsnopek commented Jun 27, 2024

I just posted draft PR #93682 which fixes the issue in my testing.

I don't know if it reintroduces the bugs that PR #86441 aimed to fix, though, and I'm going to attempt to determine that.

In any case, I'd appreciate it if other folks who are experiencing the bug described here could test if my PR fixes it for you as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Not Critical
Development

Successfully merging a pull request may close this issue.

6 participants