From 159ae74ed2ec452902913690f6d462767aa3a96d Mon Sep 17 00:00:00 2001 From: Manuel Giraud Date: Tue, 4 Jul 2023 17:57:39 +0200 Subject: [PATCH 4/4] Avoid mouse cursor flicker * src/dispextern.h (Mouse_HLInfo): Introduce a mouse_cursor_update set to true by default. * src/xdisp.c (show_mouse_face): Take it into account. (note_menu_bar_highlight, note_tab_bar_highlight) (note_tool_bar_highlight): Don't update the mouse cursor from here. --- src/dispextern.h | 5 +++++ src/xdisp.c | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/dispextern.h b/src/dispextern.h index ece128949f5..ed03a7c244e 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -2876,6 +2876,10 @@ #define PRODUCE_GLYPHS(IT) \ /* True means that the mouse highlight should not be shown. */ bool_bf mouse_face_hidden : 1; + + /* True means that the mouse highlight should update the mouse + cursor. */ + bool_bf mouse_cursor_update : 1; } Mouse_HLInfo; INLINE void @@ -2892,6 +2896,7 @@ reset_mouse_highlight (Mouse_HLInfo *hlinfo) hlinfo->mouse_face_past_end = false; hlinfo->mouse_face_hidden = false; hlinfo->mouse_face_defer = false; + hlinfo->mouse_cursor_update = true; } /*********************************************************************** diff --git a/src/xdisp.c b/src/xdisp.c index e1c4c9ee7b9..86bb1be9240 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -13956,6 +13956,11 @@ note_menu_bar_highlight (struct frame *f, int x, int y) /* On same menu-bar item as before. */ return; + /* Clear mouse face but the mouse cursor. */ + hlinfo->mouse_cursor_update = false; + clear_mouse_face (hlinfo); + hlinfo->mouse_cursor_update = true; + if (!NILP (Vmouse_highlight)) { /* Record this as the current active region. */ @@ -14838,7 +14843,10 @@ note_tab_bar_highlight (struct frame *f, int x, int y) /* On same tab-bar item as before. */ goto set_help_echo; + /* Clear mouse face but the mouse cursor. */ + hlinfo->mouse_cursor_update = false; clear_mouse_face (hlinfo); + hlinfo->mouse_cursor_update = true; bool mouse_down_p = false; /* Mouse is down, but on different tab-bar item? Or alternatively, @@ -15793,7 +15801,10 @@ note_tool_bar_highlight (struct frame *f, int x, int y) /* On same tool-bar item as before. */ goto set_help_echo; + /* Clear mouse face but the mouse cursor. */ + hlinfo->mouse_cursor_update = false; clear_mouse_face (hlinfo); + hlinfo->mouse_cursor_update = true; /* Mouse is down, but on different tool-bar item? */ mouse_down_p = (gui_mouse_grabbed (dpyinfo) @@ -33875,7 +33886,7 @@ show_mouse_face (Mouse_HLInfo *hlinfo, enum draw_glyphs_face draw) #ifdef HAVE_WINDOW_SYSTEM /* Change the mouse cursor. */ - if (FRAME_WINDOW_P (f) && NILP (track_mouse)) + if (FRAME_WINDOW_P (f) && NILP (track_mouse) && hlinfo->mouse_cursor_update) { if (draw == DRAW_NORMAL_TEXT #ifndef HAVE_EXT_MENU_BAR -- 2.40.0