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

Previous Next

Package: emacs;

Reported by: Stefan Kangas <stefankangas <at> gmail.com>

Date: Sun, 17 May 2020 04:06:02 UTC

Severity: wishlist

Tags: fixed, patch

Merged with 41342

Fixed in version 28.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

Full log


Message #63 received at 41343 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 41343 <at> debbugs.gnu.org, stefankangas <at> gmail.com
Subject: Re: bug#41343: tab-bar-mode: Close tab on mouse-2 click
Date: Wed, 11 Aug 2021 10:01:53 +0300
>> 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)))
 





This bug report was last modified 3 years and 252 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.