Subject: Re: bug#75931: 31.0.50; mouse-face and pointer properties make pointer change back and forth

From: Mauro Aranda <[email-masked]>
Date: Sat, 1 Feb 2025 16:15:14 -0300

Eli Zaretskii <[email-masked]> writes:

 >> Date: Sat, 1 Feb 2025 07:25:29 -0300
 >> Cc: [email-masked], [email-masked]
 >> From: Mauro Aranda <[email-masked]>
 >>
 >> Eli Zaretskii <[email-masked]> writes:
 >>
 >>  >> Date: Fri, 31 Jan 2025 05:52:07 -0300
 >>  >> Cc: [email-masked], [email-masked]
 >>  >> From: Mauro Aranda <[email-masked]>
 >>  >>
 >>  >> Eli Zaretskii <[email-masked]> writes:
 >>  >>
 >>  >>  >> Date: Thu, 30 Jan 2025 17:41:02 -0300
 >>  >>  >> Cc: [email-masked], [email-masked]
 >>  >>  >> From: Mauro Aranda <[email-masked]>
 >>  >>  >>
 >>  >>  >> Eli Zaretskii <[email-masked]> writes:
 >>  >>  >>
 >>  >>  >>  > Please try the patch below.
 >>  >>  >>
 >>  >>  >> Thanks, but the issue remains after applying the patch.
 >>  >>  >
 >>  >>  > That probably means that one or more other calls to 
show_mouse_face
 >>  >>  > need to be passed 'false' as the last argument. Since AFAIU 
only the
 >>  >>  > calls with DRAW_MOUSE_FACE can reset the mouse pointer back 
to the
 >>  >>  > hand shape, those are the calls that are the suspects.  So please
 >>  >>  > change each such call and see which additional one needs 
that.  I
 >> hope
 >>  >>  > there's only one such call, so please change only one call at 
a time,
 >>  >>  > each time returning the other calls to their current state.
 >>  >>
 >>  >> It's the call at the end of mouse_face_from_buffer_pos.
 >>  >
 >>  > I'm confused: didn't you say earlier in this discussion that removing
 >>  > this call to show_mouse_face in erase_phys_cursor:
 >>  >
 >>  >   #ifdef HAVE_WINDOW_SYSTEM
 >>  >     /* Since erasing the phys cursor will probably lead to 
corruption of
 >>  >        the mouse face display if the glyph's pixel_width is not 
kept up
 >>  >        to date with the :box property of the mouse face, just 
redraw the
 >>  >        mouse face, but leave the mouse cursor as it was.  */
 >>  >     if (FRAME_WINDOW_P (WINDOW_XFRAME (w)) && mouse_face_here_p)
 >>  >       {
 >>  >     w->phys_cursor_on_p = false;
 >>  >     w->phys_cursor_type = NO_CURSOR;
 >>  >     show_mouse_face (MOUSE_HL_INFO (WINDOW_XFRAME (w)), 
DRAW_MOUSE_FACE,
 >>  >              false);
 >>  >     return;
 >>  >       }
 >>  >   #endif
 >>  > solves the problem?
 >>
 >> No, I never tried removing it, I said:
 >> "Perhaps it is the call to show_mouse_face that was added to
 >> erase_phys_cursor."
 >>
 >> That was because reverting the changes in dispnew.c solved the problem
 >> after your commit, but didn't solve it anymore after the commit by Po
 >> Lu, which added that call.
 >
 > So removing both the two lines I added in dispnew.c and the above
 > snippet added by Po Lu (and leaving the rest of the code intact) does
 > solve the problem?

Yes, commenting those lines out solve it:

diff --git a/src/dispnew.c b/src/dispnew.c
index 35c8d347616..365dda47ebf 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -4595,8 +4595,8 @@ gui_update_window_end (struct window *w, bool 
cursor_on_p,
                  w->output_cursor.hpos, w->output_cursor.vpos,
                  w->output_cursor.x, w->output_cursor.y);

-      if (cursor_in_mouse_face_p (w) && cursor_on_p)
-    mouse_face_overwritten_p = 1;
+      /* if (cursor_in_mouse_face_p (w) && cursor_on_p) */
+      /*     mouse_face_overwritten_p = 1; */

        if (draw_window_fringes (w, true))
      {
diff --git a/src/xdisp.c b/src/xdisp.c
index a801caae06f..be8385feb72 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -34199,9 +34199,9 @@ erase_phys_cursor (struct window *w)
       mouse face.  */
    if (FRAME_WINDOW_P (WINDOW_XFRAME (w)) && mouse_face_here_p)
      {
-      w->phys_cursor_on_p = false;
-      w->phys_cursor_type = NO_CURSOR;
-      show_mouse_face (MOUSE_HL_INFO (WINDOW_XFRAME (w)), DRAW_MOUSE_FACE);
+      /* w->phys_cursor_on_p = false; */
+      /* w->phys_cursor_type = NO_CURSOR; */
+      /* show_mouse_face (MOUSE_HL_INFO (WINDOW_XFRAME (w)), 
DRAW_MOUSE_FACE); */
        return;
      }
  #endif