Subject: Re: bug#17588: 24.3.91; mouse-face glitchy

From: Eli Zaretskii <[email-masked]>
Date: Tue, 27 May 2014 19:04:12 +0300

> From: Christopher Schmidt <[email-masked]>
> Date: Tue, 27 May 2014 03:21:26 -0400 (EDT)
> 
> Eli Zaretskii <[email-masked]> writes:
> >> From: Christopher Schmidt <[email-masked]>
> >> Date: Mon, 26 May 2014 16:17:11 -0400 (EDT)
> >> Whenever the faulty behaviour is present, in clear_mouse_face
> >> NILP (hlinfo->mouse_face_window) is always true and therefore the
> >> highlighting is not cleared.
> >
> > Which faulty behavior: the one when there's no highlighting at all, or
> > the one when it's present, but not cleared when the mouse pointer
> > moves off the text?
> 
> The window, in which I moved my mouse pointer around, had working
> highlighting that was not cleared.

OK.

> Most of the time both issues are present.  That is, in one window
> highlighting is present but not cleared whereas in another one there is
> no highlighting at all.

Let me see if I understand this part correctly: when you move the
mouse pointer in one window showing the buffer rms2, the highlighting
is shown, but is never removed when the mouse moves from one line to
another.  When you move the mouse into another window showing the same
rms2 buffer, and let the mouse pointer in that other window hover
above the text with mouse face, the highlighting there is never shown.
Is that correct?

> >> clear_mouse_face w/o bug:
> >
> > "w/o bug" meaning what? a different Emacs version or the same version,
> > but when it behaves correctly?
> 
> That is from the very same process that exposed the issue but then
> recovered somehow.

OK, thanks.

The data you show in the debugger, viz.:

> clear_mouse_face w/ bug:
> 
>     (gdb) p *hlinfo
>      {mouse_face_beg_row = -1, mouse_face_beg_col = -1, mouse_face_beg_x = 37,
>       mouse_face_end_row = -1, mouse_face_end_col = -1, mouse_face_end_x = 0,
>       mouse_face_window = 12026738, mouse_face_face_id = 34, mouse_face_overlay = 12026738,
>       mouse_face_mouse_frame = 0x1129898, mouse_face_mouse_x = -1, mouse_face_mouse_y = -1,
>       mouse_face_past_end = false, mouse_face_defer = false, mouse_face_hidden = false}
>     (gdb) p NILP (hlinfo->mouse_face_window)
>      true

includes peculiar values -1 for both mouse_face_mouse_x and
mouse_face_mouse_y.  AFAICS, there's only one way to get these values:
if clear_mouse_face is called via note_mouse_highlight from this
function in xterm.c:

  static int
  note_mouse_movement (struct frame *frame, const XMotionEvent *event)
  {
    XRectangle *r;
    struct x_display_info *dpyinfo;

    if (!FRAME_X_OUTPUT (frame))
      return 0;

    dpyinfo = FRAME_DISPLAY_INFO (frame);
    dpyinfo->last_mouse_movement_time = event->time;
    dpyinfo->last_mouse_motion_frame = frame;
    dpyinfo->last_mouse_motion_x = event->x;
    dpyinfo->last_mouse_motion_y = event->y;

    if (event->window != FRAME_X_WINDOW (frame))
      {
	frame->mouse_moved = 1;
	dpyinfo->last_mouse_scroll_bar = NULL;
	note_mouse_highlight (frame, -1, -1);  <<<<<<<<<<<<<<<<<<<<<<<<<
	dpyinfo->last_mouse_glyph_frame = NULL;
	return 1;
      }

Can you see if clear_mouse_face is ever called from any other place,
when the highlighting isn't cleared when you move the mouse pointer to
another line of text in the same window?  If there _are_ any other
places from which clear_mouse_face is called, could you please show
the full contents of the hlinfo struct when it arrives in
clear_mouse_face in those other call sequences?

FWIW, the corresponding code on w32 is never executed when I run your
recipe and move inside and between the two windows that display the
rms2 buffer.