From 7fe5b0174fa6c9cacee1af2e67ccec1033f6d4db Mon Sep 17 00:00:00 2001 From: Oskari Alaranta Date: Sat, 30 May 2026 01:19:23 +0300 Subject: [PATCH] Allow sending enter/leave events between different native windows This fixes hovering on popups --- xbanan/Events.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/xbanan/Events.cpp b/xbanan/Events.cpp index d744ab8..a124277 100644 --- a/xbanan/Events.cpp +++ b/xbanan/Events.cpp @@ -361,12 +361,12 @@ static BAN::Vector get_path_to_child(WINDOW wid, int32_t x, int32_t y) return result; } -static void send_enter_and_leave_events(WINDOW wid, int32_t old_x, int32_t old_y, int32_t new_x, int32_t new_y) +static void send_enter_and_leave_events(WINDOW old_wid, int32_t old_x, int32_t old_y, WINDOW new_wid, int32_t new_x, int32_t new_y) { // FIXME: correct event_x and event_y values in events - const auto old_child_path = get_path_to_child(wid, old_x, old_y); - const auto new_child_path = get_path_to_child(wid, new_x, new_y); + const auto old_child_path = get_path_to_child(old_wid, old_x, old_y); + const auto new_child_path = get_path_to_child(new_wid, new_x, new_y); size_t common_ancestors = 0; while (common_ancestors < old_child_path.size() && common_ancestors < new_child_path.size()) @@ -484,7 +484,21 @@ void on_mouse_move_event(WINDOW wid, int32_t x, int32_t y) update_cursor(wid, window.cursor_x, window.cursor_y, x, y); - send_enter_and_leave_events(wid, window.cursor_x, window.cursor_y, x, y); + { + static WINDOW old_wid = g_root.windowId; + auto it = g_objects.find(old_wid); + if (it == g_objects.end()) + { + old_wid = g_root.windowId; + it = g_objects.find(g_root.windowId); + } + + ASSERT(it->value->type == Object::Type::Window); + auto& old_window = it->value->object.get(); + + send_enter_and_leave_events(old_wid, old_window.cursor_x, old_window.cursor_y, wid, x, y); + old_wid = wid; + } update_cursor_position_recursive(wid, x, y);