Subject: Re: bug#7464: 24.0.50; mouse highlighting vanishes upon unsplitting window

From: Eli Zaretskii <[email-masked]>
Date: Fri, 30 Mar 2012 15:06:36 +0300

> From: Stephen Berman <[email-masked]>
> Cc: [email-masked],  [email-masked]
> Date: Fri, 30 Mar 2012 13:08:53 +0200
> 
> I'm not sure this is still appropriate for the bugtracker

I think it's appropriate, as we still don't understand exactly what
restores the highlighting in the GTK build.

> I cannot tell in gdb when I'm in the window with the mouse face
> highlighting.

Whenever you are in update_window, typing "pp w->buffer" should
display the buffer this window is displaying.  I get to this function
3 times, with these self-explanatory results:

  Breakpoint 5, update_window (w=0x3574200, force_p=1) at dispnew.c:3547
  3547      struct glyph_matrix *desired_matrix = w->desired_matrix;
  (gdb) pp w->buffer
  nil
  (gdb) c
  Continuing.

  Breakpoint 5, update_window (w=0x356bc00, force_p=1) at dispnew.c:3547
  3547      struct glyph_matrix *desired_matrix = w->desired_matrix;
  (gdb) pp w->buffer
  #<buffer *GNU Emacs*>
  (gdb) c
  Continuing.

  Breakpoint 5, update_window (w=0x356ba00, force_p=1) at dispnew.c:3547
  3547      struct glyph_matrix *desired_matrix = w->desired_matrix;
  (gdb) pp w->buffer
  #<buffer  *Minibuf-0*>

So in my case, the second call is for the window we are interested in.
(The window whose buffer is nil is the root window of the frame, which
does not display anything; it is the root of the tree of all the
windows on that frame.)

>   Breakpoint 7, update_window (w=0x8711888, force_p=1)
>       at /data/steve/bzr/emacs/quickfixes/src/dispnew.c:3547
>   3547      struct glyph_matrix *desired_matrix = w->desired_matrix;
>   (gdb) n
>   [...]
>   3655                changed_p |= update_window_line (w, vpos,
>   (gdb) p w
>   $9 = (struct window *) 0x8711888
> 
> Or is this the window with the mouse face highlighting?
> 
>   (gdb) p vpos
>   $10 = 0
>   (gdb)  p mouse_face_overwritten_p
>   $11 = 0
> 
> The highlighted text (still visible in the Emacs window) is in line 2,
> so why is mouse_face_overwritten_p already 0?

This variable starts as zero.  If update_window_line finds a line with
a mouse highlight, it sets it to one; otherwise it doesn't touch it.
So if _any_ line in the window has mouse highlight, this variable will
end up being 1; otherwise it will stay at zero.

>   Breakpoint 7, update_window (w=0x86f0e48, force_p=1)
>       at /data/steve/bzr/emacs/quickfixes/src/dispnew.c:3547
>   3547      struct glyph_matrix *desired_matrix = w->desired_matrix;
>   (gdb) n
>   [...]
>   3655                changed_p |= update_window_line (w, vpos,
>   (gdb) p vpos
>   $15 = 0
>   (gdb)  p mouse_face_overwritten_p
>   $16 = 0
> 
> Fourth window...
> 
>   (gdb) c
>   Continuing.
> 
> At this point the highlighting vanished.  Does that mean the fourth
> window is the one that contained the highlighting?

Maybe, maybe not.  To know exactly where the highlighting disappeared,
keep stepping with 'n', even after you exit update_window, until you
find the source line that actually clears the highlighting.  (Yes, it
could take a while, sorry, but I don't have a better suggestion.)
Then we will have our culprit, or at least the clue where to look for
it (since the line that clears the highlighting could be a call to
another function; then you'd need to step into it, etc.).

> I guess the four windows are the two vertically deployed windows (one of
> which was deleted at the beginning) displaying the buffer in which I
> typed "test" on line 2 + the window displaying the minibuffer + the root
> window; is this right?

Yes; but "pp w->buffer" will tell.

> Why do they all show mouse_face_overwritten_p = 0 at line 1 and how
> can I tell which one contained the highlighted text?

I hope this is clear now.

Thanks.