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

From: Stephen Berman <[email-masked]>
Date: Fri, 30 Mar 2012 21:35:27 +0200

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

>> 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.  

Thanks for this very helpful tip.

[...]
>> 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.

Hm, I have failed to find where its value becomes 1; every time I typed
`p mouse_face_overwritten_p' while stepping over the code, the value was
0.  I also tried `watch mouse_face_overwritten_p' at each update_window
breakpoint: that found where the value was set to 0, but every other
watchpoint was deleted unchanged after the program left the containing
block.

[...]
> 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.).

Here's the protocol of an attempt to do this (with the Athena build of
Emacs 24):

Breakpoint 3, Fdelete_other_windows_internal (window=141560709, root=139227370)
    at /data/steve/bzr/emacs/quickfixes/src/window.c:2569
2569      w = decode_any_window (window);
(gdb) br redisplay_internal
Breakpoint 22 at 0x8084dee: file /data/steve/bzr/emacs/quickfixes/src/xdisp.c, line 12669.
(gdb) c
Continuing.

Breakpoint 22, redisplay_internal ()
    at /data/steve/bzr/emacs/quickfixes/src/xdisp.c:12669
12669     struct window *w = XWINDOW (selected_window);
(gdb) br update_window
Breakpoint 23 at 0x8059e53: file /data/steve/bzr/emacs/quickfixes/src/dispnew.c, line 3547.
(gdb) c
Continuing.

Breakpoint 23, update_window (w=0x86c07f0, force_p=1)
    at /data/steve/bzr/emacs/quickfixes/src/dispnew.c:3547
3547      struct glyph_matrix *desired_matrix = w->desired_matrix;
(gdb) c
Continuing.

Breakpoint 23, update_window (w=0x8700b80, force_p=1)
    at /data/steve/bzr/emacs/quickfixes/src/dispnew.c:3547
3547      struct glyph_matrix *desired_matrix = w->desired_matrix;
(gdb) c
Continuing.

Breakpoint 23, update_window (w=0x8712ae0, force_p=1)
    at /data/steve/bzr/emacs/quickfixes/src/dispnew.c:3547
3547      struct glyph_matrix *desired_matrix = w->desired_matrix;
(gdb) pp w->buffer
#<buffer  *Minibuf-0*>
(gdb) n
3552      struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w)));
(gdb) fin
Run till exit from #0  update_window (w=0x8712ae0, force_p=1)
    at /data/steve/bzr/emacs/quickfixes/src/dispnew.c:3552
0x080598af in update_window_tree (w=0x8712ae0, force_p=1)
    at /data/steve/bzr/emacs/quickfixes/src/dispnew.c:3355
3355            paused_p |= update_window (w, force_p);
Value returned is $25 = 0
(gdb) n
3357          w = NILP (w->next) ? 0 : XWINDOW (w->next);
(gdb) fin
Run till exit from #0  update_window_tree (w=0x8712ae0, force_p=1)
    at /data/steve/bzr/emacs/quickfixes/src/dispnew.c:3357
0x08059692 in update_frame (f=0x8700a00, force_p=1, inhibit_hairy_id_p=0)
    at /data/steve/bzr/emacs/quickfixes/src/dispnew.c:3282
3282          paused_p = update_window_tree (root_window, force_p);
Value returned is $26 = 0
(gdb) n
3283          update_end (f);
(gdb) fin
Run till exit from #0  update_frame (f=0x8700a00, force_p=1, 
    inhibit_hairy_id_p=0)
    at /data/steve/bzr/emacs/quickfixes/src/dispnew.c:3283
0x08085fca in redisplay_internal ()
    at /data/steve/bzr/emacs/quickfixes/src/xdisp.c:13213
13213                     pending |= update_frame (f, 0, 0);
Value returned is $27 = 0
(gdb) n
13214                     f->updated_p = 1;
(gdb) fin
Run till exit from #0  redisplay_internal ()
    at /data/steve/bzr/emacs/quickfixes/src/xdisp.c:13214
redisplay () at /data/steve/bzr/emacs/quickfixes/src/xdisp.c:12400
12400   }
(gdb) n
read_char (commandflag=1, nmaps=2, maps=0xbfffe6e0, prev_event=139227370, 
    used_mouse_menu=0xbfffe7b8, end_time=0x0)
    at /data/steve/bzr/emacs/quickfixes/src/keyboard.c:2448
2448              if (!input_pending)
(gdb) fin
Run till exit from #0  read_char (commandflag=1, nmaps=2, maps=0xbfffe6e0, 
    prev_event=139227370, used_mouse_menu=0xbfffe7b8, end_time=0x0)
    at /data/steve/bzr/emacs/quickfixes/src/keyboard.c:2448

Breakpoint 22, redisplay_internal ()
    at /data/steve/bzr/emacs/quickfixes/src/xdisp.c:12669
12669     struct window *w = XWINDOW (selected_window);
(gdb) n
12673     int must_finish = 0;
(gdb) fin
Run till exit from #0  redisplay_internal ()
    at /data/steve/bzr/emacs/quickfixes/src/xdisp.c:12673

Breakpoint 23, update_window (w=0x8700b80, force_p=1)
    at /data/steve/bzr/emacs/quickfixes/src/dispnew.c:3547
3547      struct glyph_matrix *desired_matrix = w->desired_matrix;
(gdb) pp w->buffer
#<buffer a>
(gdb) n
3552      struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w)));
(gdb) fin
Run till exit from #0  update_window (w=0x8700b80, force_p=1)
    at /data/steve/bzr/emacs/quickfixes/src/dispnew.c:3552
0x080598af in update_window_tree (w=0x8700b80, force_p=1)
    at /data/steve/bzr/emacs/quickfixes/src/dispnew.c:3355
3355            paused_p |= update_window (w, force_p);
Value returned is $28 = 0
(gdb) n
3357          w = NILP (w->next) ? 0 : XWINDOW (w->next);
(gdb) fin
Run till exit from #0  update_window_tree (w=0x8700b80, force_p=1)
    at /data/steve/bzr/emacs/quickfixes/src/dispnew.c:3357
0x08059692 in update_frame (f=0x8700a00, force_p=1, inhibit_hairy_id_p=0)
    at /data/steve/bzr/emacs/quickfixes/src/dispnew.c:3282
3282          paused_p = update_window_tree (root_window, force_p);
Value returned is $29 = 0
(gdb) n
3283          update_end (f);
(gdb) fin
Run till exit from #0  update_frame (f=0x8700a00, force_p=1, 
    inhibit_hairy_id_p=0)
    at /data/steve/bzr/emacs/quickfixes/src/dispnew.c:3283
0x080861f9 in redisplay_internal ()
    at /data/steve/bzr/emacs/quickfixes/src/xdisp.c:13276
13276             pending = update_frame (sf, 0, 0);
Value returned is $30 = 0
(gdb) n
13284         mini_window = FRAME_MINIBUF_WINDOW (sf);
(gdb) fin
Run till exit from #0  redisplay_internal ()
    at /data/steve/bzr/emacs/quickfixes/src/xdisp.c:13284
redisplay_preserve_echo_area (from_where=7)
    at /data/steve/bzr/emacs/quickfixes/src/xdisp.c:13433
13433     if (FRAME_RIF (SELECTED_FRAME ()) != NULL
(gdb) s
13434         && FRAME_RIF (SELECTED_FRAME ())->flush_display_optional)
(gdb) 
13435       FRAME_RIF (SELECTED_FRAME ())->flush_display_optional (NULL);
(gdb) 
x_flush (f=0x0) at /data/steve/bzr/emacs/quickfixes/src/xterm.c:373
373       if (!NILP (Vinhibit_redisplay))
(gdb) 
376       BLOCK_INPUT;
(gdb) 
377       if (f == NULL)
(gdb) 
380           FOR_EACH_FRAME (rest, frame)
(gdb) 
381             if (FRAME_X_P (XFRAME (frame)))
(gdb) 
382               x_flush (XFRAME (frame));
(gdb) 
x_flush (f=0x8700a00) at /data/steve/bzr/emacs/quickfixes/src/xterm.c:373
373       if (!NILP (Vinhibit_redisplay))
(gdb) 
376       BLOCK_INPUT;
(gdb) 
377       if (f == NULL)
(gdb) 
384       else if (FRAME_X_P (f))
(gdb) 
385         XFlush (FRAME_X_DISPLAY (f));
(gdb) 
386       UNBLOCK_INPUT;

When I hit RET at the gdb prompt before UNBLOCK_INPUT, the highlighting
vanished.

Steve Berman