From 9d1ae05442a710dd23053ef42a9c3c0f65813110 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Tue, 8 Feb 2022 14:17:23 +0800 Subject: [PATCH] Clear mouse highlight when mouse moves outside edit widget * src/xterm.c (handle_one_xevent): Clear mouse highlight when leaving the edit widget. Otherwise, it stays around on the toolbar after the mouse is moved onto the menu bar. --- src/xterm.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/xterm.c b/src/xterm.c index b49441ddb79..8bdb3c9ea1b 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -10068,8 +10068,17 @@ handle_one_xevent (struct x_display_info *dpyinfo, if (x_top_window_to_frame (dpyinfo, event->xcrossing.window)) x_detect_focus_change (dpyinfo, any, event, &inev.ie); +#if defined USE_X_TOOLKIT + /* If the mouse leaves the edit widget, then any mouse highlight + should be cleared. */ + f = x_window_to_frame (dpyinfo, event->xcrossing.window); + + if (!f) + f = x_top_window_to_frame (dpyinfo, event->xcrossing.window); +#else f = x_top_window_to_frame (dpyinfo, event->xcrossing.window); -#if defined HAVE_X_TOOLKIT && defined HAVE_XINPUT2 +#endif +#if defined USE_X_TOOLKIT && defined HAVE_XINPUT2 /* The XI2 event mask is set on the frame widget, so this event likely originates from the shell widget, which we aren't interested in. */ @@ -10783,15 +10792,15 @@ handle_one_xevent (struct x_display_info *dpyinfo, if (any) x_detect_focus_change (dpyinfo, any, event, &inev.ie); - if (!any) - any = x_any_window_to_frame (dpyinfo, leave->event); - #ifndef USE_X_TOOLKIT f = x_top_window_to_frame (dpyinfo, leave->event); #else /* On Xt builds that have XI2, the enter and leave event masks are set on the frame widget's window. */ f = x_window_to_frame (dpyinfo, leave->event); + + if (!f) + f = x_top_window_to_frame (dpyinfo, leave->event); #endif if (f) { -- 2.39.5