Subject: bug#47581: 27.1; tab-bar missed mouse clicks on MS-Windows

From: Juri Linkov <[email-masked]>
Date: Mon, 05 Apr 2021 02:00:47 +0300

> I think the actual problem is elsewhere: in handle_tab_bar_click.  It
> includes code that was copied from handle_tool_bar_click, and which
> pays attention to the value of mouse-highlight.  But tab-bar buttons
> don't behave like tool-bar buttons in this regard: they don't respond
> to moving the mouse pointer to them by "activating" the button.  So I
> think that code should be removed from handle_tab_bar_click.  To wit:
> turn mouse-highlight off (M-x set-variable RET mouse-highlight RET nil
> RET), and clicks on tab-bar buttons miraculously start working with
> 100% reliability.
>
> Juri, why is that code present in handle_tab_bar_click?  Is that just
> a copy/paste from handle_tool_bar_click, or is there some reason for
> that?  I'm talking about this logic, and the comments which describe
> it, in handle_tab_bar_click:

Indeed, this code was copied from handle_tool_bar_click,
but this extra logic was not removed because there are parts
of the tab bar that should respond to moving the mouse pointer,
namely the tab close buttons are activated when the mouse pointer
is moved over them.  But I'm not sure if this feature is related
to this code, or won't be affected by removing this code.

>   /* If not on the highlighted tab-bar item, and mouse-highlight is
>      non-nil, return.  This is so we generate the tab-bar button
>      click only when the mouse button is released on the same item as
>      where it was pressed.  However, when mouse-highlight is disabled,
>      generate the click when the button is released regardless of the
>      highlight, since tab-bar items are not highlighted in that
>      case.  */
>   frame_to_window_pixel_xy (w, &x, &y);
>   ts = get_tab_bar_item (f, x, y, &glyph, &hpos, &vpos, &prop_idx, &close_p);
>   if (ts == -1
>       || (ts != 0 && !NILP (Vmouse_highlight)))
>     return;
>
>   /* When mouse-highlight is off, generate the click for the item
>      where the button was pressed, disregarding where it was
>      released.  */
>   if (NILP (Vmouse_highlight) && !down_p)
>     prop_idx = f->last_tab_bar_item;