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

From: Stephen Berman <[email-masked]>
Date: Fri, 30 Mar 2012 10:44:52 +0200

On Fri, 30 Mar 2012 09:35:45 +0300 Eli Zaretskii <[email-masked]> wrote:

> When update_window_line updates the screen line that has some
> characters highlighted, it should set mouse_face_overwritten_p to a
> non-zero value.  So either step over the call to update_window_line
> (i.e. 'n' instead of 's'), or, if you stepped into it, type "finish",
> and then look at the value of mouse_face_overwritten_p after the call.
> But please do it for the row with highlight; e.g., if it's the 2nd
> screen line, do it when the value of vpos is 1.

I tried to make a simple test case, but I think I still don't understand
exactly what to do.  I started my Athena build, in order to circumvent
GTK+ interference with Emacs redisplay, under gdb with -Q, set a
breakpoint at Fdelete_other_windows_internal, in Emacs switched to a new
buffer, typed "test" at line 1, column 0 and then M-: (put-text-property
(point-min) (point-max) 'mouse-face 'highlight).  Then I typed C-x 2,
put the mouse over the word "test", highlighting it, typed C-x 1 and
proceeded in gdb thus:

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

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

Breakpoint 5, update_window (w=0x86b1998, force_p=1)
    at /data/steve/bzr/emacs/quickfixes/src/dispnew.c:3547
3547      struct glyph_matrix *desired_matrix = w->desired_matrix;
(gdb) p w->current_matrix
$1 = (struct glyph_matrix *) 0x86c77e0
(gdb) p w->current_matrix->rows
$2 = (struct glyph_row *) 0x8918298
(gdb) p (w->current_matrix->rows+1)->mouse_face_p
$3 = 0
(gdb) n
3552      struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w)));
(gdb) 
3566      if (force_p || !input_pending || !NILP (do_mouse_tracking))
(gdb) 
3571          int yb, changed_p = 0, mouse_face_overwritten_p = 0;
(gdb) 
3576          rif->update_window_begin_hook (w);
(gdb) 
3577          yb = window_text_bottom_y (w);
(gdb) 
3578          row = desired_matrix->rows;
(gdb) 
3579          end = row + desired_matrix->nrows - 1;
(gdb) 
3583          if (row->mode_line_p)
(gdb) 
3589            header_line_row = NULL;
(gdb) 
3592          mode_line_row = MATRIX_MODE_LINE_ROW (desired_matrix);
(gdb) 
3593          if (mode_line_row->mode_line_p && mode_line_row->enabled_p)
(gdb) 
3604          while (row < end && !row->enabled_p)
(gdb) 
3608          if (row < end && !desired_matrix->no_scrolling_p)
(gdb) 
3629            if (row->enabled_p)
(gdb) 
3631                int vpos = MATRIX_ROW_VPOS (row, desired_matrix);
(gdb) p vpos
$4 = 268435456
(gdb) 
$5 = 268435456
(gdb) n
3639                if (!force_p)
(gdb) 
3655                changed_p |= update_window_line (w, vpos,
(gdb) p vpos
$6 = 0
(gdb) n
3667                if (MATRIX_ROW_BOTTOM_Y (row) >= yb)
(gdb) p vpos
$7 = 0
(gdb) p mouse_face_overwritten_p
$8 = 0
(gdb) n
3626          for (; row < end && (force_p || !input_pending); ++row)
(gdb) 
3629            if (row->enabled_p)
(gdb) 
3631                int vpos = MATRIX_ROW_VPOS (row, desired_matrix);
(gdb) 
3639                if (!force_p)
(gdb) 
3655                changed_p |= update_window_line (w, vpos,
(gdb) p vpos
$9 = 1
(gdb) p mouse_face_overwritten_p
$10 = 0
(gdb) n
3667                if (MATRIX_ROW_BOTTOM_Y (row) >= yb)
(gdb) p mouse_face_overwritten_p
$11 = 0

At this point (vpos = 1) aren't we past the highlighted text?  Yet
nothing has changed.  What I am doing wrong?

Steve Berman