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

From: Po Lu <[email-masked]>
Date: Mon, 20 Sep 2021 16:18:01 +0800

Eli Zaretskii <[email-masked]> writes:

> Actually, it looks like we already do everything we need to account
> for the box border, when it exists, while drawing the glyphs (in
> xterm.c/w32term.c).  The pixel_width of the glyphs is not used by the
> back-end code which actually draws to the glass.  So the only place
> which needs fixing is probably draw_phys_cursor_glyph and maybe also
> erase_phys_cursor.  Assuming we are indeed talking about problems with
> the glyph under the cursor.

My understanding is that when the cursor is drawn, the string in
RIF->draw_glyph_string contains _only_ the glyph underneath the cursor,
while the terminals only compensate for the box if the first glyph in
the string has a left box line; when drawing a cursor on the area with a
mouse face, that is only true if the cursor lands on the start of the
box.

In addition to that, draw_phys_cursor_glyph uses the value
w->output_cursor.x as the X offset passed to draw_glyphs, so I still
don't think the problem lies in draw_phys_cursor_glyph, but either in
where the cursor position is calculated (by tallying up the
pixel_widths), or where the mouse face is drawn without updating the
contents of the glyph row to reflect the potentially changed dimensions.
Personally, I still think the problem lies in the latter area and not
the former, but I'll leave that up to your judgement.

BTW, in x_set_cursor_gc, I notice that s->face isn't being set to the
mouse face even when the cursor lies inside the mouse face.  Perhaps
checking for cursor_in_mouse_face_p (s->w), and setting s->face to the
mouse face when that is the case would be prudent?  AFAIK, something
similar is already being done in x_draw_stretch_glyph_string (see this
chunk of code):

	  if (s->row->mouse_face_p
	      && cursor_in_mouse_face_p (s->w))
	    {
	      x_set_mouse_face_gc (s);
	      gc = s->gc;
	    }

Thanks.