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

From: Mauro Aranda <[email-masked]>
Date: Thu, 30 Jan 2025 09:05:23 -0300

On 30/1/25 08:36, Eli Zaretskii wrote:
 >> Date: Thu, 30 Jan 2025 06:57:32 -0300
 >> Cc: [email-masked]
 >> From: Mauro Aranda <[email-masked]>
 >>
 >> Now, if I go back to your commit, then commenting out that change in
 >> dispnew.c does indeed solve the problem.  But the next commit to xdisp.c
 >> is this:
 >> commit 2028df7826bb2c2909b2aaeba47282ca70c514e3
 >> Author: Po Lu <[email-masked]>
 >> Date:   Thu Oct 14 18:38:26 2021 +0800
 >>
 >>      Fix minor issues with text display when cursor is in mouse face
 >>
 >>       * src/xdisp.c (get_cursor_offset_for_mouse_face): Don't calculate
 >>      offsets for the glyph the cursor is on, and move some logic to
 >>      get_glyph_pixel_width_delta_for_mouse_face.
 >>      (fill_composite_glyph_string)
 >>      (fill_gstring_glyph_string)
 >>      (fill_glyphless_glyph_string)
 >>      (fill_glyph_string)
 >>      (fill_image_glyph_string)
 >>      (fill_xwidget_glyph_string)
 >>      (fill_stretch_glyph_string): Set s->face to mouse face whenever
 >>      appropriate.
 >>      (get_glyph_pixel_width_delta_for_mouse_face): New function.
 >>      (set_glyph_string_background_width): Update background width and
 >>      s->width to take into account differing :box properties of the 
mouse
 >>      face, when producing strings for the cursor.
 >>      (erase_phys_cursor): Redraw mouse face when erasing a cursor on 
top of
 >>      the mouse face.
 >>       * src/xterm.c (x_set_mouse_face_gc): Stop setting s->face when 
under
 >>      mouse face because redisplay now does that for us.
 >>       * src/w32term.c (w32_set_mouse_face_gc): Likewise.
 >>
 >> And that commit makes the issue reappear.  And as I said, now reverting
 >> the change in dispnew.c only solves half the problem.
 >>
 >> Perhaps it is the call to show_mouse_face that was added to
 >> erase_phys_cursor.
 >
 > Yes, I think so.  If you arrange for that call to show_mouse_face to
 > not redefine the mouse cursor near the end of show_mouse_face, does
 > the problem go away? or do you still need to revert those two lines in
 > dispnew.c added by my changes?

I've no idea how to do that.  So, I did something silly:
In show_mouse_face, when draw is DRAW_MOUSE_FACE, I changed:
FRAME_OUTPUT_DATA (f)->hand_cursor
to:
FRAME_OUTPUT_DATA (f)->current_cursor

With that change, I don't need to revert the changes in dispnew.c.

But I'm way out of my league here, so I don't know if the change is
correct, most probably not.  What seems correct is not specifying
hand_cursor, but rather find out which cursor do we need to draw when
redrawing it...

With the change I did, specifying pointer to hourglass (for example),
works.  And not specifying it, shows the hand pointer, as it should.