From f515ff05e086e74b203b91fb4fba319e24e0fb54 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Fri, 6 May 2022 11:55:35 +0800 Subject: [PATCH] Fix mouse face persisting inside Lucid menus on XI2 * src/xmenu.c (create_and_show_popup_menu): Call `x_mouse_leave' on Lucid as well when the input extension is being used. * src/xterm.c (x_mouse_leave): Enable on Lucid XI2 builds. * src/xterm.h: Update prototypes. --- src/xmenu.c | 5 +++++ src/xterm.c | 11 ++++++++++- src/xterm.h | 3 ++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/xmenu.c b/src/xmenu.c index 0dbc8058f9e..4c8828412d3 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -1844,6 +1844,11 @@ create_and_show_popup_menu (struct frame *f, widget_value *first_wv, #ifdef HAVE_XINPUT2 prepare_for_entry_into_toolkit_menu (f); + +#ifdef USE_LUCID + if (dpyinfo->supports_xi2) + x_mouse_leave (dpyinfo); +#endif #endif /* Display the menu. */ lw_popup_menu (menu, &dummy); diff --git a/src/xterm.c b/src/xterm.c index 1f3e44c553f..6b5c272ef9b 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -10333,12 +10333,21 @@ x_detect_focus_change (struct x_display_info *dpyinfo, struct frame *frame, } -#if !defined USE_X_TOOLKIT && !defined USE_GTK +#if (defined USE_LUCID && defined HAVE_XINPUT2) \ + || (!defined USE_X_TOOLKIT && !defined USE_GTK) /* Handle an event saying the mouse has moved out of an Emacs frame. */ void x_mouse_leave (struct x_display_info *dpyinfo) { + Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight; + + if (hlinfo->mouse_face_mouse_frame) + { + clear_mouse_face (hlinfo); + hlinfo->mouse_face_mouse_frame = NULL; + } + x_new_focus_frame (dpyinfo, dpyinfo->x_focus_event_frame); } #endif diff --git a/src/xterm.h b/src/xterm.h index 74e6d1a96cb..3e06564bee9 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -1386,7 +1386,8 @@ extern bool x_alloc_lighter_color_for_widget (Widget, Display *, Colormap, extern bool x_alloc_nearest_color (struct frame *, Colormap, XColor *); extern void x_query_colors (struct frame *f, XColor *, int); extern void x_clear_area (struct frame *f, int, int, int, int); -#if !defined USE_X_TOOLKIT && !defined USE_GTK +#if (defined USE_LUCID && defined HAVE_XINPUT2) \ + || (!defined USE_X_TOOLKIT && !defined USE_GTK) extern void x_mouse_leave (struct x_display_info *); #endif -- 2.39.5