Subject: Re: bug#50424: 27.2; Tab bar button mouse face not clearing entirely

From: Juri Linkov <[email-masked]>
Date: Sun, 12 Sep 2021 10:06:09 +0300

>> >> With enlarged height and width, now the buttons are not vertically
>> >> aligned:
>> >
>> > Is this a screenshot of a tab bar or of a tab line?
>>
>> Tab bar.  And the change was caused by your commit db74a93659.
>
> Then I don't understand the two horizontally-adjacent images.  What
> are they? two separate frame?  If they are two frames, then where are
> the frame decorations?  In short, I don't understand what am I seeing
> there, and how did you get this display.

These are two separate images that show the changed tab dimensions
before changes when :margin was (2 . 0), and after changes
when now :margin is 4.

> And also, when you say "buttons are not vertically aligned", what
> exactly do you mean?  Not aligned with what?

Now buttons are not aligned to the baseline, and thus are
not centered vertically anymore.

>> db74a93659 that contains such changes:
>>
>> - :margin (2 . 0)
>> + :margin ,tab-bar-button-margin
>
> This is to make the code do what the variable's documentation says.
> Without that change, the images were sized using :margin '(2 . 0)',
> but the C code used the value of tab-bar-button-margin, a simple
> scalar, to place the image and clear its background.  The way to
> affect the image dimensions is by changing the value of
> tab-bar-button-margin, not by hard-coding the margin in the image
> properties.

This patch restores the original tab dimensions, while also keeps fixed
the reported problem of mouse face not clearing entirely:

diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 8be08d4b8b..edbadec09d 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -161,7 +161,7 @@ tab-bar--load-buttons
     (add-text-properties 0 (length tab-bar-new-button)
                          `(display (image :type xpm
                                           :file "tabs/new.xpm"
-                                          :margin ,tab-bar-button-margin
+                                          :margin ,(cons tab-bar-button-margin 0)
                                           :ascent center))
                          tab-bar-new-button))
 
@@ -171,7 +171,7 @@ tab-bar--load-buttons
     (add-text-properties 0 (length tab-bar-close-button)
                          `(display (image :type xpm
                                           :file "tabs/close.xpm"
-                                          :margin ,tab-bar-button-margin
+                                          :margin ,(cons tab-bar-button-margin 0)
                                           :ascent center))
                          tab-bar-close-button)))
 
@@ -1659,7 +1659,7 @@ tab-bar-history-mode
           (add-text-properties 0 (length tab-bar-back-button)
                                `(display (image :type xpm
                                                 :file "tabs/left-arrow.xpm"
-                                                :margin ,tab-bar-button-margin
+                                                :margin ,(cons tab-bar-button-margin 0)
                                                 :ascent center))
                                tab-bar-back-button))
         (when (and tab-bar-mode (not (get-text-property 0 'display tab-bar-forward-button)))
@@ -1667,7 +1667,7 @@ tab-bar-history-mode
           (add-text-properties 0 (length tab-bar-forward-button)
                                `(display (image :type xpm
                                                 :file "tabs/right-arrow.xpm"
-                                                :margin ,tab-bar-button-margin
+                                                :margin ,(cons tab-bar-button-margin 0)
                                                 :ascent center))
                                tab-bar-forward-button))
 
diff --git a/src/dispextern.h b/src/dispextern.h
index f4c7575b35..0ede76ebf5 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -3202,7 +3202,7 @@ #define IMAGE_CACHE_BUCKETS_SIZE 1001
 
 /* Default values of the above variables.  */
 
-#define DEFAULT_TAB_BAR_BUTTON_MARGIN 4
+#define DEFAULT_TAB_BAR_BUTTON_MARGIN 2
 #define DEFAULT_TAB_BAR_BUTTON_RELIEF 1
 
 /* The height in pixels of the default tab-bar images.  */