Subject: bug#51298: 29.0.50; Tab bar buttons won't highlight after the mouse is released outside the tab bar

From: Po Lu <[email-masked]>
Date: Wed, 20 Oct 2021 15:40:05 +0800

Juri Linkov <[email-masked]> writes:

> Patches welcome.

Thanks, please test.  The issue was because f->last_tab_bar_item
wouldn't be cleared when the mouse click was dropped outside the tab
bar.

>From 0b56777754cc5112c35c04d1da2a1154eed6e0bd Mon Sep 17 00:00:00 2001
From: Po Lu <[email-masked]>
Date: Wed, 20 Oct 2021 15:36:59 +0800
Subject: [PATCH] Fix tab bar item highlight when a mouse click is dropped

* src/xdisp.c (note_mouse_highlight): Clear last_tab_bar_item if the
movement wasn't made on top of the tab bar.
---
 src/xdisp.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/xdisp.c b/src/xdisp.c
index 1a65066ef9..888bf2d88d 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -33786,6 +33786,14 @@ note_mouse_highlight (struct frame *f, int x, int y)
       else
 	return;
     }
+  else
+    {
+      /* The mouse might have pressed into the tab bar, but might
+	 also have been released outside the tab bar, so
+	 f->last_tab_bar_item must be reset, in order to make sure the
+	 item can be still highlighted again in the future.  */
+      f->last_tab_bar_item = -1;
+    }
 #endif
 
 #if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
-- 
2.31.1