From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#68698: 30.0.50; Making xt-mouse emit `wheel-up/down` Date: Thu, 25 Jan 2024 09:30:05 +0200 Message-ID: <86o7d9dg5e.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24276"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 68698@debbugs.gnu.org To: Stefan Monnier , Jared Finder Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 25 08:31:40 2024 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 1rSuD6-00063v-C9 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 25 Jan 2024 08:31:40 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rSuCr-0007RQ-4c; Thu, 25 Jan 2024 02:31:25 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rSuCO-0007Pt-TA for bug-gnu-emacs@gnu.org; Thu, 25 Jan 2024 02:30:58 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rSuCO-0008JN-E9 for bug-gnu-emacs@gnu.org; Thu, 25 Jan 2024 02:30:56 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rSuCT-0001cL-NL for bug-gnu-emacs@gnu.org; Thu, 25 Jan 2024 02:31:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 25 Jan 2024 07:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68698 X-GNU-PR-Package: emacs Original-Received: via spool by 68698-submit@debbugs.gnu.org id=B68698.17061678246173 (code B ref 68698); Thu, 25 Jan 2024 07:31:01 +0000 Original-Received: (at 68698) by debbugs.gnu.org; 25 Jan 2024 07:30:24 +0000 Original-Received: from localhost ([127.0.0.1]:47190 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rSuBr-0001bV-J2 for submit@debbugs.gnu.org; Thu, 25 Jan 2024 02:30:23 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44644) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rSuBp-0001bH-6z for 68698@debbugs.gnu.org; Thu, 25 Jan 2024 02:30:21 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rSuBc-0008Ey-PC; Thu, 25 Jan 2024 02:30:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=KamgTEK4Ca/NhbK4Hjm4DV9hZ4YihZL9uUcuCdUOTFo=; b=Wc5ElR9JTZOX gzSq+Ffod/Di/Ukkyo2ZJrOZLw1C2ewyxpOkCHjPyXbvsYBXGfdEO19l2yz4gK4wkk0YS4IWekOYT TE1+/99ScfQ9aKcSEVXL3LXw5Omgf6ZqvHJM4nP1AXmEFPGUna3PKoq+6d5tQaPN+NHaxcbP+HyhE 9Rf5wS2nIsUTiW6b4B0mH35AW+xXLL3x/mTksuvIdf65EhqiX6n6f/2xtYDbyEKEDuexMMGNGUQk3 EZ9/NPfhV4GkAy+d9wzsLU55yVHxv3pTelnhCtc9kkTpZ0PHTGKTvdrkniIwAJPt1rvsiK+/O7mDT d/sE7sAQBYbbtXFjuCOlwQ==; In-Reply-To: (bug-gnu-emacs@gnu.org) 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:278833 Archived-At: > Date: Wed, 24 Jan 2024 15:31:32 -0500 > From: Stefan Monnier via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > Package: Emacs > Version: 30.0.50 > > > Currently, wheel-up/down events are generated in most setups instead > of the old mouse-4/5. There are still two exceptions: > - X11 builds not using XInput2. > - text terminals. > The attached patch intends to fix the second bullet. > Text terminals themselves only give us info equivalent to `mouse-4/5` > and don't actually tell us that it's a wheel movement, but we can still > turn those things into `wheel-up/down`. > > This is related to bug#49803. Jared, any comments on the patch, or related issues? Thanks. > The second step would be to do something similar for the non-XInput2 X11 > build: make it generate `wheel-up/down` events according to > `mouse-wheel-down/up-event` settings. Then packages like > `completion-preview` and `mwheel` won't need to pay attention to the > (confusingly named) `mouse-wheel-down/up-event` vars any more. > > > Stefan > > diff --git a/lisp/mwheel.el b/lisp/mwheel.el > index 53042085bf6..66a1fa1a706 100644 > --- a/lisp/mwheel.el > +++ b/lisp/mwheel.el > @@ -59,7 +59,7 @@ mouse-wheel-change-button > (defvar mouse-wheel-obey-old-style-wheel-buttons t > "If non-nil, treat mouse-4/5/6/7 events as mouse wheel events. > These are the event names used historically in X11 before XInput2. > -They are sometimes generated by things like `xterm-mouse-mode' as well.") > +They are sometimes generated by things like text-terminals as well.") > > (defcustom mouse-wheel-down-event > (if mouse-wheel-obey-old-style-wheel-buttons 'mouse-4) > diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el > index cd00467f14f..fcc0db1d9eb 100644 > --- a/lisp/xt-mouse.el > +++ b/lisp/xt-mouse.el > @@ -40,6 +40,8 @@ > > ;;; Code: > > +(require 'mwheel) > + > (defvar xterm-mouse-debug-buffer nil) > > (defun xterm-mouse-translate (_event) > @@ -193,6 +195,12 @@ xterm-mouse--read-number-from-terminal > (cons n c)) > (cons (- (setq c (xterm-mouse--read-coordinate)) 32) c)))) > > +(defun xterm-mouse--same-button-p (event btn) > + (and (symbolp event) > + (string-prefix-p "mouse-" (symbol-name event)) > + (eq btn (car (read-from-string (symbol-name event) > + (length "mouse-")))))) > + > ;; XTerm reports mouse events as > ;; in default mode, and > ;; ";" ";" <"M" or "m"> in extended mode. > @@ -231,12 +239,24 @@ xterm-mouse--read-event-sequence > ;; event: assume, that the last button was button 1. > (t 1))) > (sym (if move 'mouse-movement > - (intern (concat (if ctrl "C-" "") > - (if meta "M-" "") > - (if shift "S-" "") > - (if down "down-" "") > - "mouse-" > - (number-to-string btn)))))) > + (intern > + (concat > + (if ctrl "C-" "") > + (if meta "M-" "") > + (if shift "S-" "") > + (if down "down-" "") > + (cond > + ;; BEWARE: `mouse-wheel-UP-event' corresponds to > + ;; `wheel-DOWN' events and vice versa!! > + ((xterm-mouse--same-button-p mouse-wheel-down-event btn) > + "wheel-up") > + ((xterm-mouse--same-button-p mouse-wheel-up-event btn) > + "wheel-down") > + ((xterm-mouse--same-button-p mouse-wheel-left-event btn) > + "wheel-left") > + ((xterm-mouse--same-button-p mouse-wheel-right-event btn) > + "wheel-right") > + (t (format "mouse-%d" btn)))))))) > (list sym (1- x) (1- y)))) > > (defun xterm-mouse--set-click-count (event click-count)