From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#41343: tab-bar-mode: Close tab on mouse-2 click Date: Wed, 11 Aug 2021 10:01:53 +0300 Organization: LINKOV.NET Message-ID: <87k0ksecbq.fsf@mail.linkov.net> References: <87wnp2cg52.fsf@linkov.net> <83tuk5la2u.fsf@gnu.org> <877dh18lj3.fsf@mail.linkov.net> <83y29gjvjh.fsf@gnu.org> <8735rn8jz6.fsf@mail.linkov.net> <83sfznhywm.fsf@gnu.org> <87tuk356ia.fsf@mail.linkov.net> <83im0iiw8n.fsf@gnu.org> <877dgvkt1z.fsf@mail.linkov.net> <83wnotfpak.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31554"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: 41343@debbugs.gnu.org, stefankangas@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 11 09:08:31 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mDiLm-00084d-JK for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 11 Aug 2021 09:08:30 +0200 Original-Received: from localhost ([::1]:57372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDiLl-0002ms-Li for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 11 Aug 2021 03:08:29 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44828) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDiKM-0000dv-9h for bug-gnu-emacs@gnu.org; Wed, 11 Aug 2021 03:07:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49798) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mDiKM-00038s-3c for bug-gnu-emacs@gnu.org; Wed, 11 Aug 2021 03:07:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mDiKL-0000CZ-QB for bug-gnu-emacs@gnu.org; Wed, 11 Aug 2021 03:07:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 11 Aug 2021 07:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41343 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 41343-submit@debbugs.gnu.org id=B41343.1628665562668 (code B ref 41343); Wed, 11 Aug 2021 07:07:01 +0000 Original-Received: (at 41343) by debbugs.gnu.org; 11 Aug 2021 07:06:02 +0000 Original-Received: from localhost ([127.0.0.1]:33107 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mDiJO-0000Ac-0w for submit@debbugs.gnu.org; Wed, 11 Aug 2021 03:06:02 -0400 Original-Received: from relay4-d.mail.gandi.net ([217.70.183.196]:35911) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mDiJM-0000AC-5h for 41343@debbugs.gnu.org; Wed, 11 Aug 2021 03:06:00 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 8688EE0003; Wed, 11 Aug 2021 07:05:53 +0000 (UTC) In-Reply-To: <83wnotfpak.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 10 Aug 2021 15:38:11 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:211553 Archived-At: >> 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 (# (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)))