From 04f5364646dbbb5dc493ec5cf9918672c6154e6d Mon Sep 17 00:00:00 2001 From: Cliear <1979454239@qq.com> Date: Thu, 25 Jul 2024 20:21:20 +0800 Subject: [PATCH] fix popup window can not receive events immediately when the mouse enters --- platform/linuxbsd/x11/display_server_x11.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/platform/linuxbsd/x11/display_server_x11.cpp b/platform/linuxbsd/x11/display_server_x11.cpp index 6736896bafe..e67d3a8ce60 100644 --- a/platform/linuxbsd/x11/display_server_x11.cpp +++ b/platform/linuxbsd/x11/display_server_x11.cpp @@ -4989,10 +4989,16 @@ void DisplayServerX11::process_events() { last_mouse_pos = pos; - if (focused_window_id != window_id) { - // Adjust event position relative to window distance when event is sent to a different window. - mm->set_position(mm->get_position() - window_get_position(focused_window_id) + window_get_position(window_id)); - mm->set_global_position(mm->get_position()); + if (windows[focused_window_id].mpass || wd.is_popup) { + mm->set_window_id(window_id); + } else { + int x, y; + Window child; + XTranslateCoordinates(x11_display, wd.x11_window, windows[focused_window_id].x11_window, event.xmotion.x, event.xmotion.y, &x, &y, &child); + + Point2i pos_focused(x, y); + mm->set_position(pos_focused); + mm->set_global_position(pos_focused); } Input::get_singleton()->parse_input_event(mm);