Subject: Re: bug#20590: mouse-highlight does not do as documented

From: Johan Bockgård <[email-masked]>
Date: Sat, 16 May 2015 22:06:02 +0200

Eli Zaretskii <[email-masked]> writes:

>> Date: Sat, 16 May 2015 11:09:33 -0700
>> From: Samuel Wales <[email-masked]>
>> 
>> mouse-highlight does not do as documented, which seems to be a bug.
>> 
>> i confirmed with emacs -Q.  i did not find a similar bug report.
>> 
>> ===
>> 
>> "If the value is an integer, highlighting is only shown
>> after moving the mouse, while keyboard input turns off the
>> highlight even when the mouse is over the clickable text."
>> 
>> in my usage, highlighting shows when mouse has not moved.
>> it also shows when there is keyboard input.
>
> I cannot reproduce this.  You didn't show a precise recipe you used,
> so here's mine:
>
>  . emacs -Q
>  . C-h v mouse-highlight RET
>  . move the mouse pointer above the hyper-link labeled "C source code"
>    and observe the highlight
>  . type some character -- the highlight stays on
>  . M-x set-variable RET mouse-highlight RET 1 RET
>  . type some character -- the highlight goes off
>  . move the mouse pointer a bit -- the highlight goes on
>
> So the highlight behaves as documented for me.
>
> For the record, I tried both Emacs 24.4, which is what you seem to
> have, and the latest development sources.

The problem was introduced by

commit 742516e02048d3bbfba4e6e13dd19afa097bbd3b
Author: Dmitry Antipov <[email-masked]>
Date:   Wed Sep 11 12:56:33 2013 +0400

    Ifdef away frame tool bar code when it is not really used.
    ...

The bug does not exist on Windows. I think this should fix it:

diff --git a/src/xterm.c b/src/xterm.c
index d9032fa..0537491 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -7056,17 +7056,18 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 
       f = any;
 
-#if ! defined (USE_GTK)
       /* If mouse-highlight is an integer, input clears out
 	 mouse highlighting.  */
       if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)
+#if ! defined (USE_GTK)
 	  && (f == 0
-	      || !EQ (f->tool_bar_window, hlinfo->mouse_face_window)))
+	      || !EQ (f->tool_bar_window, hlinfo->mouse_face_window))
+#endif
+	  )
         {
           clear_mouse_face (hlinfo);
           hlinfo->mouse_face_hidden = true;
         }
-#endif
 
 #if defined USE_MOTIF && defined USE_TOOLKIT_SCROLL_BARS
       if (f == 0)