unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 41343@debbugs.gnu.org, stefankangas@gmail.com
Subject: bug#41343: tab-bar-mode: Close tab on mouse-2 click
Date: Wed, 11 Aug 2021 10:01:53 +0300	[thread overview]
Message-ID: <87k0ksecbq.fsf@mail.linkov.net> (raw)
In-Reply-To: <83wnotfpak.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 10 Aug 2021 15:38:11 +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)))
 






  reply	other threads:[~2021-08-11  7:01 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-17  4:05 bug#41343: tab-bar-mode: Close tab on mouse-2 click Stefan Kangas
2020-05-17 22:12 ` Juri Linkov
2020-05-17 22:23   ` Stefan Kangas
2020-05-18  2:32   ` Eli Zaretskii
2020-05-19 21:54     ` Juri Linkov
2020-05-20 15:59       ` Eli Zaretskii
2021-08-03 22:33 ` Juri Linkov
2021-08-04 11:32   ` Eli Zaretskii
2021-08-04 20:13     ` Juri Linkov
2021-08-05  5:43       ` Eli Zaretskii
2021-08-06  0:41         ` Juri Linkov
2021-08-06  6:26           ` Eli Zaretskii
2021-08-06  8:20             ` Juri Linkov
2021-08-06 12:38               ` Eli Zaretskii
2021-08-09  7:03                 ` Juri Linkov
2021-08-10 12:38                   ` Eli Zaretskii
2021-08-11  7:01                     ` Juri Linkov [this message]
2021-08-11 11:56                       ` Eli Zaretskii
2021-08-12  8:09                         ` Juri Linkov
2021-08-12  8:43                           ` Eli Zaretskii
2021-08-13  7:24                             ` Juri Linkov
2021-08-18 18:11                         ` Juri Linkov
2021-08-24 14:37                           ` Stefan Kangas
2021-09-05 17:18                             ` Juri Linkov
2021-09-06 19:40                               ` Stefan Kangas
2021-09-08 19:28                                 ` Juri Linkov
2021-09-08 21:18                                   ` Stefan Kangas
2021-09-14  6:43                                 ` Juri Linkov
2021-09-05 17:17                         ` Juri Linkov
2021-08-06 16:21           ` bug#41343: [External] : " Drew Adams
2021-08-09  7:06             ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k0ksecbq.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=41343@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=stefankangas@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).