Merge pull request #96829 from dsnopek/x11-focus-bugs-take-twenty-seven-million-and-four

Fix project manager stealing focus on i3
This commit is contained in:
Rémi Verschelde 2024-09-18 11:15:30 +02:00
commit 1d3e9b3688
No known key found for this signature in database
GPG Key ID: C3336907360768E1
3 changed files with 7 additions and 3 deletions

View File

@ -2998,7 +2998,11 @@ bool DisplayServerX11::window_is_focused(WindowID p_window) const {
const WindowData &wd = windows[p_window]; 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 { bool DisplayServerX11::window_can_draw(WindowID p_window) const {

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)) { if (wid == DisplayServer::INVALID_WINDOW_ID || !DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_IME) || !DisplayServer::get_singleton()->window_is_focused(wid)) {
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)) { if (wid == DisplayServer::INVALID_WINDOW_ID || !DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_IME) || !DisplayServer::get_singleton()->window_is_focused(wid)) {
return; return;
} }
DisplayServer::get_singleton()->window_set_ime_active(true, wid); DisplayServer::get_singleton()->window_set_ime_active(true, wid);