TextEditor loses focus on Linux

Hi! I’m facing this issue, where the TextEditor seems to gain keyboard focus briefly (caret appears) but then loses it immediately again. The focus is gained by calling grabKeyboardFocus().

I’ve tested the methods focusGained() focusLost() and the assignable lambda onFocusLost() and from the output it seems the focus is gained, but never lost.
However, if I check hasKeyboardFocus(), it will return false. So it hasn’t lost keyboard focus, but still doesn’t have it?

When I manually click inside the editor again, another focusGained() will appear, before ever calling a focusLost().

What could be the issue here? This only happens on Linux. Win and Mac work fine.
JUCE 7.0.1 (just realizing now I might want to try upgrading JUCE…)

Thanks!

On Linux you need to give a bit more context. Like which window manager or desktop environment are you using? Is it on Xorg or Wayland (with xwayland) ?

I’m using the i3 window manager, so that’s on Xorg

In the meantime I found a hacky workaround: Where the focus is grabbed, I just grab it again after 200ms on Linux:

    ...

    m_text_editor.grabKeyboardFocus();

#ifdef SPLINE_LINUX
    juce::Timer::callAfterDelay (200, [&]() { m_text_editor.grabKeyboardFocus(); });
#endif

    ...

A long shot from a clean solution, but the user has to transition from the mouse to the keyboard anyways, so it should be fine.

I wonder if this is the same/similar issue described here?

Might be related, but in your case the caret seems to stay visible, while it vanishes for me.