Subject: Re: bug#50660: 28.0.50; Text artifacting when the cursor moves over text under mouse face that originally displayed a box

From: Eli Zaretskii <[email-masked]>
Date: Tue, 21 Sep 2021 15:26:19 +0300

> Date: Tue, 21 Sep 2021 13:41:28 +0300
> From: Eli Zaretskii <[email-masked]>
> Cc: [email-masked], [email-masked], [email-masked]
> 
> Here's a specific idea: add the same code which fixes the cursor
> position into gui_update_window_end, before display_and_set_cursor is
> called, here:
> 
>   if (!w->pseudo_window_p)
>     {
>       block_input ();
> 
>       if (cursor_on_p)
> 	display_and_set_cursor (w, true,
> 				w->output_cursor.hpos, w->output_cursor.vpos,
> 				w->output_cursor.x, w->output_cursor.y);
> 
>       if (draw_window_fringes (w, true))
> 	{
> 	  if (WINDOW_RIGHT_DIVIDER_WIDTH (w))
> 	    gui_draw_right_divider (w);
> 	  else
> 	    gui_draw_vertical_border (w);
> 	}
>       unblock_input ();
>     }
> 
> This is always called when the display is updated, even if we just
> move the cursor.  By looking at the value of cursor_in_mouse_face_p,
> we can determine whether the fix is needed, and apply it before
> calling display_and_set_cursor.  (We will need to fix w->phys_cursor.x
> after the call to display_and_set_cursor returns, because it records
> there the value passed as the 5th argument.)

Actually, it looks like it would be enough to set
mouse_face_overwritten_p = true in gui_update_window_end, when the
cursor is inside mouse face highlighted text.  Then, as the comments
near the end of gui_update_window_end tell, this function already
arranges for the mouse-highlight to be redisplayed, and that will call
show_mouse_face.