Fix renaming nodes on X11

This commit is contained in:
David Snopek 2024-09-25 08:52:27 -05:00
parent 4254946de9
commit 36293a2dbf
3 changed files with 5 additions and 9 deletions

View file

@ -2998,11 +2998,7 @@ bool DisplayServerX11::window_is_focused(WindowID p_window) const {
const WindowData &wd = windows[p_window]; const WindowData &wd = windows[p_window];
Window focused_window; return wd.focused;
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 { bool DisplayServerX11::window_can_draw(WindowID p_window) const {
@ -3050,7 +3046,7 @@ void DisplayServerX11::window_set_ime_active(const bool p_active, WindowID p_win
XWindowAttributes xwa; XWindowAttributes xwa;
XSync(x11_display, False); XSync(x11_display, False);
XGetWindowAttributes(x11_display, wd.x11_xim_window, &xwa); XGetWindowAttributes(x11_display, wd.x11_xim_window, &xwa);
if (xwa.map_state == IsViewable) { if (xwa.map_state == IsViewable && _window_focus_check()) {
_set_input_focus(wd.x11_xim_window, RevertToParent); _set_input_focus(wd.x11_xim_window, RevertToParent);
} }
XSetICFocus(wd.xic); XSetICFocus(wd.xic);
@ -4319,7 +4315,7 @@ bool DisplayServerX11::_window_focus_check() {
bool has_focus = false; bool has_focus = false;
for (const KeyValue<int, DisplayServerX11::WindowData> &wid : windows) { for (const KeyValue<int, DisplayServerX11::WindowData> &wid : windows) {
if (wid.value.x11_window == focused_window) { if (wid.value.x11_window == focused_window || (wid.value.xic && wid.value.ime_active && wid.value.x11_xim_window == focused_window)) {
has_focus = true; has_focus = true;
break; break;
} }

View file

@ -103,7 +103,7 @@ void LineEdit::_close_ime_window() {
void LineEdit::_update_ime_window_position() { void LineEdit::_update_ime_window_position() {
DisplayServer::WindowID wid = get_window() ? get_window()->get_window_id() : DisplayServer::INVALID_WINDOW_ID; 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) || !DisplayServer::get_singleton()->window_is_focused(wid)) { if (wid == DisplayServer::INVALID_WINDOW_ID || !DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_IME)) {
return; return;
} }
DisplayServer::get_singleton()->window_set_ime_active(true, wid); DisplayServer::get_singleton()->window_set_ime_active(true, wid);

View file

@ -2958,7 +2958,7 @@ void TextEdit::_close_ime_window() {
void TextEdit::_update_ime_window_position() { void TextEdit::_update_ime_window_position() {
DisplayServer::WindowID wid = get_window() ? get_window()->get_window_id() : DisplayServer::INVALID_WINDOW_ID; 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) || !DisplayServer::get_singleton()->window_is_focused(wid)) { if (wid == DisplayServer::INVALID_WINDOW_ID || !DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_IME)) {
return; return;
} }
DisplayServer::get_singleton()->window_set_ime_active(true, wid); DisplayServer::get_singleton()->window_set_ime_active(true, wid);