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

From: Christopher Schmidt <[email-masked]>
Date: Wed, 28 May 2014 16:15:25 -0400 (EDT)

Eli Zaretskii <[email-masked]> writes:
>> From: Christopher Schmidt <[email-masked]>
>> Date: Wed, 28 May 2014 08:27:57 -0400 (EDT)
>>
>> (gdb) bt
>> #0  clear_mouse_face (hlinfo=hlinfo@entry=0x1394780)
>>     at xdisp.c:27495
>> #1  0x0000000000457fef in note_mouse_highlight (
>>     f=f@entry=0x1129898, x=494, y=378) at xdisp.c:28812
>                            ^^^^^
> Does this large value of x make sense?  AFAIU, you are in the lower
> window showing the buffer rms2, and you move the mouse above the text
> in that window.  The text lines in that buffer are very short, so I
> wonder how come you get such a large value of the x coordinate.

You've got me there.

This is what I use for testing:

    (run-at-time nil 0.01
                 (lambda ()
                   (with-current-buffer (get-buffer-create "rms")
                     (with-silent-modifications
                       (dotimes (_ 10)
                         (insert (if (= (random 2) 1) "gpl" "fsf") "\n"))
                       (when (> (- (point-max) (point-min)) 100)
                         (delete-region (point-min) (+ (point-min) 100)))))))
    (with-current-buffer (get-buffer-create "rms2")
      (dotimes (i 1000)
        (insert (propertize (format "%3d%3d%3d" i i i)
                            'mouse-face 'highlight)
                "\n")))
    (with-selected-window (split-window-below)
      (with-selected-window (split-window-right)
        (switch-to-buffer "rms2"))
      (switch-to-buffer "rms2"))
    (with-selected-window (split-window-right)
      (switch-to-buffer "rms"))

The snippet is loaded at startup via the --load option.  As startup.el
claims the first window to display the initial buffer, I switched to a
four window setup.

> So are you saying that clear_mouse_face is never called with non-nil
> hlinfo->mouse_face_window?  IOW, if you put a conditional breakpoint
> in clear_mouse_face, like this:
>
>   (gdb) break clear_mouse_face if hlinfo->mouse_face_window != Qnil
>
> then this breakpoint never breaks, is that right?

Yes, it never breaks.

> If so, I'd like to see which code resets mouse_face_window to nil,
> after it is set by show_mouse_face.  (We know that it must be set by
> show_mouse_face because you do see the highlighting when the mouse is
> above text with mouse-face.)  To this end, set a breakpoint in
> show_mouse_face, like this:
>
>   (gdb) break show_mouse_face if draw == DRAW_MOUSE_FACE

The watchpoint is triggered in turns as part of the following two
contexts.  Qnil is 12026738.

    Hardware watchpoint 12: -location hlinfo->mouse_face_window

    Old value = 12026738
    New value = 18193773
    mouse_face_from_buffer_pos (disp_string=12026738, after_string=12026738,
        before_string=12026738, end_charpos=<optimized out>, start_charpos=6711,
        mouse_charpos=6717, hlinfo=<optimized out>, window=18193773) at xdisp.c:28062
    28062                                       !hlinfo->mouse_face_hidden, -1);
    #0  mouse_face_from_buffer_pos (disp_string=12026738, after_string=12026738,
        before_string=12026738, end_charpos=<optimized out>, start_charpos=6711,
        mouse_charpos=6717, hlinfo=<optimized out>, window=18193773) at xdisp.c:28062
    #1  note_mouse_highlight (f=f@entry=0x1129898, x=<optimized out>,
        y=<optimized out>) at xdisp.c:29151
    #2  0x00000000004b4b86 in note_mouse_movement (frame=frame@entry=0x1129898,
        event=event@entry=0x7fffffffdc80) at xterm.c:3887
    #3  0x00000000004bcb09 in handle_one_xevent (dpyinfo=dpyinfo@entry=0x1396000,
        event=event@entry=0x7fffffffdc80, finish=finish@entry=0xb071e0,
        hold_quit=0x7fffffffdea0) at xterm.c:6644
    #4  0x00000000004be320 in event_handler_gdk (gxev=0x7fffffffdc80,
        ev=<optimized out>, data=<optimized out>) at xterm.c:5720
    #5  0x00007ffff65cca2a in ?? () from /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0
    #6  0x00007ffff65ce6f6 in ?? () from /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0
    #7  0x00007ffff65ce77e in ?? () from /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0
    #8  0x00007ffff4a89355 in g_main_context_dispatch ()
       from /lib/x86_64-linux-gnu/libglib-2.0.so.0
    #9  0x00007ffff4a89688 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
    #10 0x00007ffff4a89744 in g_main_context_iteration ()
       from /lib/x86_64-linux-gnu/libglib-2.0.so.0
    #11 0x00007ffff69609a1 in gtk_main_iteration ()
       from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
    #12 0x00000000004b6d82 in XTread_socket (terminal=<optimized out>,
        hold_quit=0x7fffffffdea0) at xterm.c:7013
    #13 0x00000000004e8be1 in gobble_input () at keyboard.c:6849
    #14 0x00000000004e8605 in handle_async_input () at keyboard.c:7089
    #15 process_pending_signals () at keyboard.c:7103
    #16 0x0000000000590e6e in wait_reading_process_output (
        time_limit=time_limit@entry=30, nsecs=nsecs@entry=0,
        read_kbd=read_kbd@entry=-1, do_display=do_display@entry=true,
        wait_for_cell=12026738, wait_proc=wait_proc@entry=0x0, just_wait_proc=0)
        at process.c:4340
    #17 0x000000000041f363 in sit_for (timeout=<optimized out>,
        reading=reading@entry=true, display_option=display_option@entry=1)
        at dispnew.c:5805
    #18 0x00000000004eca63 in read_char (commandflag=1, map=map@entry=19249734,
        prev_event=12026738, used_mouse_menu=used_mouse_menu@entry=0x7fffffffe58b,
        end_time=end_time@entry=0x0) at keyboard.c:2809
    #19 0x00000000004edc75 in read_key_sequence (keybuf=keybuf@entry=0x7fffffffe660,
        prompt=12026738, dont_downcase_last=dont_downcase_last@entry=false,
        can_return_switch_frame=can_return_switch_frame@entry=true,
        fix_current_buffer=fix_current_buffer@entry=true,
        prevent_redisplay=prevent_redisplay@entry=false, bufsize=30) at keyboard.c:9087
    #20 0x00000000004ef950 in command_loop_1 () at keyboard.c:1452
    #21 0x0000000000550977 in internal_condition_case (
        bfun=bfun@entry=0x4ef760 <command_loop_1>, handlers=<optimized out>,
        hfun=hfun@entry=0x4e6bf0 <cmd_error>) at eval.c:1354
    #22 0x00000000004e234e in command_loop_2 (ignore=ignore@entry=12026738)
        at keyboard.c:1177
    #23 0x000000000055085b in internal_catch (tag=12073890,
        func=func@entry=0x4e2330 <command_loop_2>, arg=12026738) at eval.c:1118
    #24 0x00000000004e6807 in command_loop () at keyboard.c:1156
    #25 recursive_edit_1 () at keyboard.c:777
    #26 0x00000000004e6b20 in Frecursive_edit () at keyboard.c:848
    #27 0x0000000000415ab9 in main (argc=0, argv=0x7fffffffe9a8) at
    emacs.c:1646

    Hardware watchpoint 12: -location hlinfo->mouse_face_window

    Old value = 18193773
    New value = 12026738
    reset_mouse_highlight (hlinfo=0x13960a0) at dispextern.h:2725
    2725            hlinfo->mouse_face_overlay = Qnil;
    #0  reset_mouse_highlight (hlinfo=0x13960a0) at dispextern.h:2725
    #1  x_update_window_end (w=0x1139998, cursor_on_p=<optimized out>,
        mouse_face_overwritten_p=<optimized out>) at xterm.c:600
    #2  0x000000000041b17d in update_window (w=w@entry=0x1139998,
        force_p=<optimized out>, force_p@entry=true) at dispnew.c:3486
    #3  0x000000000041c3fb in update_window_tree (w=0x1139998,
        force_p=force_p@entry=true) at dispnew.c:3161
    #4  0x000000000041c3ee in update_window_tree (w=0x1144a48,
        force_p=force_p@entry=true) at dispnew.c:3159
    #5  0x000000000041c3ee in update_window_tree (w=w@entry=0x1148c60,
        force_p=force_p@entry=true) at dispnew.c:3159
    #6  0x000000000041e59d in update_frame (f=0x1129898, force_p=<optimized out>,
        inhibit_hairy_id_p=<optimized out>) at dispnew.c:3059
    #7  0x000000000044c0df in redisplay_internal () at xdisp.c:13844
    #8  0x000000000044e0d0 in redisplay_preserve_echo_area (
        from_where=from_where@entry=9) at xdisp.c:14058
    #9  0x00000000005902a8 in wait_reading_process_output (
        time_limit=time_limit@entry=30, nsecs=nsecs@entry=0,
        read_kbd=read_kbd@entry=-1, do_display=do_display@entry=true,
        wait_for_cell=12026738, wait_proc=wait_proc@entry=0x0, just_wait_proc=0)
        at process.c:4398
    #10 0x000000000041f363 in sit_for (timeout=<optimized out>,
        reading=reading@entry=true, display_option=display_option@entry=1)
        at dispnew.c:5805
    #11 0x00000000004eca63 in read_char (commandflag=1, map=map@entry=19249734,
        prev_event=12026738, used_mouse_menu=used_mouse_menu@entry=0x7fffffffe58b,
        end_time=end_time@entry=0x0) at keyboard.c:2809
    #12 0x00000000004edc75 in read_key_sequence (keybuf=keybuf@entry=0x7fffffffe660,
        prompt=12026738, dont_downcase_last=dont_downcase_last@entry=false,
        can_return_switch_frame=can_return_switch_frame@entry=true,
        fix_current_buffer=fix_current_buffer@entry=true,
        prevent_redisplay=prevent_redisplay@entry=false, bufsize=30) at keyboard.c:9087
    #13 0x00000000004ef950 in command_loop_1 () at keyboard.c:1452
    #14 0x0000000000550977 in internal_condition_case (
        bfun=bfun@entry=0x4ef760 <command_loop_1>, handlers=<optimized out>,
        hfun=hfun@entry=0x4e6bf0 <cmd_error>) at eval.c:1354
    #15 0x00000000004e234e in command_loop_2 (ignore=ignore@entry=12026738)
        at keyboard.c:1177
    #16 0x000000000055085b in internal_catch (tag=12073890,
        func=func@entry=0x4e2330 <command_loop_2>, arg=12026738) at eval.c:1118
    #17 0x00000000004e6807 in command_loop () at keyboard.c:1156
    #18 recursive_edit_1 () at keyboard.c:777
    #19 0x00000000004e6b20 in Frecursive_edit () at keyboard.c:848
    #20 0x0000000000415ab9 in main (argc=0, argv=0x7fffffffe9a8) at emacs.c:1646