diff --git a/platform/linuxbsd/x11/display_server_x11.cpp b/platform/linuxbsd/x11/display_server_x11.cpp index 499df55befe..a12c9352736 100644 --- a/platform/linuxbsd/x11/display_server_x11.cpp +++ b/platform/linuxbsd/x11/display_server_x11.cpp @@ -2998,7 +2998,11 @@ bool DisplayServerX11::window_is_focused(WindowID p_window) const { const WindowData &wd = windows[p_window]; - return wd.focused; + Window focused_window; + int focus_ret_state; + XGetInputFocus(x11_display, &focused_window, &focus_ret_state); + + return wd.x11_window == focused_window; } bool DisplayServerX11::window_can_draw(WindowID p_window) const { diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 1a066b07286..a08fb96e71d 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -103,7 +103,7 @@ void LineEdit::_close_ime_window() { void LineEdit::_update_ime_window_position() { DisplayServer::WindowID wid = get_window() ? get_window()->get_window_id() : DisplayServer::INVALID_WINDOW_ID; - if (wid == DisplayServer::INVALID_WINDOW_ID || !DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_IME)) { + if (wid == DisplayServer::INVALID_WINDOW_ID || !DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_IME) || !DisplayServer::get_singleton()->window_is_focused(wid)) { return; } DisplayServer::get_singleton()->window_set_ime_active(true, wid); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index d7799588ead..bf9c479c698 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -2958,7 +2958,7 @@ void TextEdit::_close_ime_window() { void TextEdit::_update_ime_window_position() { DisplayServer::WindowID wid = get_window() ? get_window()->get_window_id() : DisplayServer::INVALID_WINDOW_ID; - if (wid == DisplayServer::INVALID_WINDOW_ID || !DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_IME)) { + if (wid == DisplayServer::INVALID_WINDOW_ID || !DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_IME) || !DisplayServer::get_singleton()->window_is_focused(wid)) { return; } DisplayServer::get_singleton()->window_set_ime_active(true, wid);