Subject: bug#50993: 29.0.50; Problems when dragging the mouse over the toolbar

From: martin rudalics <[email-masked]>
Date: Thu, 14 Oct 2021 19:01:52 +0200

> Do you mean adding 'mouse-face highlight' to tab strings?
 > It has no effect on the tab bar.  Maybe something is missing
 > in note_tab_bar_highlight?

Probably.  Try the attached only "cursorily" tested patch.

martin
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index ccecdbc044..162c721751 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -113,6 +113,8 @@ tab-bar-select-tab-modifiers
   :group 'tab-bar
   :version "27.1")

+(defvar tab-bar-drag-maybe)
+
 (defun tab-bar--define-keys ()
   "Install key bindings for switching between tabs if the user has configured them."
   (when tab-bar-select-tab-modifiers
@@ -236,6 +238,7 @@ tab-bar--key-to-number
    (t t)))

 (defun tab-bar--event-to-item (posn)
+  (setq tab-bar-drag-maybe nil)
   (if (posn-window posn)
       (let ((caption (car (posn-string posn))))
         (when caption
@@ -263,6 +266,7 @@ tab-bar-mouse-select-tab
   (interactive "e")
   (let* ((item (tab-bar--event-to-item (event-start event)))
          (tab-number (tab-bar--key-to-number (nth 0 item))))
+    (setq tab-bar-drag-maybe t)
     ;; Don't close the tab when clicked on the close button.
     ;; Let `tab-bar-mouse-close-tab-from-button' do this.
     (unless (nth 2 item)
@@ -331,6 +335,7 @@ tab-bar-mouse-context-menu

 (defun tab-bar-mouse-move-tab (event)
   (interactive "e")
+  (setq tab-bar-drag-maybe nil)
   (let ((from (tab-bar--key-to-number
                (nth 0 (tab-bar--event-to-item
                        (event-start event)))))
diff --git a/src/xdisp.c b/src/xdisp.c
index f802e89834..eb6e717a5b 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -33411,7 +33411,13 @@ note_mouse_highlight (struct frame *f, int x, int y)
   if (EQ (window, f->tab_bar_window))
     {
       note_tab_bar_highlight (f, x, y);
-      return;
+      if (tab_bar_drag_maybe)
+	{
+	  cursor = FRAME_OUTPUT_DATA (f)->hand_cursor;
+	  goto set_cursor;
+	}
+      else
+	return;
     }
 #endif

@@ -35543,6 +35549,10 @@ syms_of_xdisp (void)
 mouse stays within the extent of a single glyph (except for images).  */);
   mouse_fine_grained_tracking = false;

+  DEFVAR_BOOL ("tab-bar-drag-maybe", tab_bar_drag_maybe,
+    doc: /* Non-nil when maybe dragging tab bar item.  */);
+  tab_bar_drag_maybe = false;
+
   DEFVAR_BOOL ("redisplay-skip-initial-frame", redisplay_skip_initial_frame,
     doc: /* Non-nil to skip redisplay in initial frame.
 The initial frame is not displayed anywhere, so skipping it is