bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#41343: tab-bar-mode: Close tab on mouse-2 click


From: Juri Linkov
Subject: bug#41343: tab-bar-mode: Close tab on mouse-2 click
Date: Wed, 11 Aug 2021 10:01:53 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

>> So now I've completely redesigned the event processing on the tab bar.
>
> Thanks, this looks much, much better to me.

Could you please help to check if everything is correct
on the Windows part (unfortunately, I don't have Windows).
The changes in w32inevt.c and w32term.c just mirror the changes
in xdisp.c and xterm.c, but I'm sure I might have made a typo.
I could push the changes to a new branch if you want.

There is the need to apply an additional patch below,
because the tab symbol is carried by the event in its
OBJECT slot, but some functions expect that the OBJECT
slot should contain only (STRING . STRING-POS)

The Info node (info "(elisp) Click Events") documents
the event format as:

  (WINDOW POS-OR-AREA (X . Y) TIMESTAMP
   OBJECT TEXT-POS (COL . ROW)
   IMAGE (DX . DY) (WIDTH . HEIGHT))

and the events emitted by the previous patch look like:

  (down-mouse-1 (#<frame...> (tab-bar) (X . Y) TIMESTAMP (tab-5 t)))

where '(tab-5 t)' in the OBJECT slot defines the clicked tab symbol
and whether the close button was clicked.

And I can't find a slot more suitable than OBJECT to carry event metadata.

diff --git a/lisp/mouse.el b/lisp/mouse.el
index cf7c17be28..557d9ab1df 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -1176,7 +1362,7 @@ mouse-posn-property
 its value is returned."
   (if (consp pos)
       (let ((w (posn-window pos)) (pt (posn-point pos))
-           (str (posn-string pos)))
+           (str (unless (eq (posn-area pos) 'tab-bar) (posn-string pos))))
         ;; FIXME: When STR has a `category' property and there's another
         ;; `category' property at PT, we should probably disregard the
         ;; `category' property at PT while doing the (get-char-property
@@ -1187,7 +1373,8 @@ mouse-posn-property
             ;; (nth 5).  This is useful but is not exactly where we clicked, so
             ;; don't look up that position's properties!
            (and pt (not (memq (posn-area pos) '(left-fringe right-fringe
-                                                 left-margin right-margin)))
+                                                 left-margin right-margin
+                                                 tab-bar)))
                 (get-char-property pt property w))))
     (get-char-property pos property)))
 






reply via email to

[Prev in Thread] Current Thread [Next in Thread]