Subject: bug#50798: 28.0.50; Tab line close button is off-center until it is highlighted with the mouse

From: Juri Linkov <[email-masked]>
Date: Sat, 02 Oct 2021 22:36:15 +0300

> Please tell more about what you saw there.  Which X coordinates are
> miscalculated?
>
> And I don't think I understand the arrangement with faces for the
> close button.  tab-line.el says:
>
>   (defvar tab-line-close-button
>     (propertize " x"
> 		'display '(image :type xpm
> 				 :file "tabs/close.xpm"
> 				 :margin (2 . 0)
> 				 :ascent center)
> 		'keymap tab-line-tab-close-map
> 		'mouse-face 'tab-line-close-highlight
> 		'help-echo "Click to close tab")
>     "Button for closing the clicked tab.")
>
> which seems to mean we should use 'tab-line-close-highlight' as the
> mouse-face for this button.  But if I invoke (tab-line-format), which
> seems to be what calculates the tab-line-format, I see this:
>
> (#(" xdisp.c x"
>  1 8
>    (tab #<buffer xdisp.c>
>     face tab-line-tab-inactive
>     mouse-face tab-line-highlight
>     follow-link ignore)
>  8 10
>    (tab #<buffer xdisp.c>
>     face tab-line-tab-inactive
>     display (image :type xpm :file "tabs/close.xpm" :margin (2 . 0) :ascent center)
>     mouse-face tab-line-highlight ...
>
> which seems to say we actually use the 'tab-line-highlight' face
> instead for the close button?
>
> Could you please describe how mouse-highlight faces are supposed to
> work with tab-line close buttons, and preferably walk me through the
> relevant code?

'tab-line-close-highlight' was supposed to be applied to the close button
to emulate how the close button behaves on the tab bar where hovering mouse
over the button displays it with the face style 'released-button'.

But mouse-face of the face 'tab-line-highlight' overrides the mouse-face
'tab-line-close-highlight' in 'tab-line-tab-name-format-default'
that applies 'propertize' with 'mouse-face tab-line-highlight'.
And I can't find a way how to keep the existing 'mouse-face' property on
the close button while applying 'mouse-face tab-line-highlight' to the
rest of the tab.