From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#68698: 30.0.50; Making xt-mouse emit `wheel-up/down` Date: Wed, 24 Jan 2024 15:31:32 -0500 Message-ID: Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25635"; mail-complaints-to="usenet@ciao.gmane.io" To: 68698@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jan 24 21:34:15 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 1rSjws-0006Nd-Qn for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 24 Jan 2024 21:34:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rSjwd-0003Ln-OY; Wed, 24 Jan 2024 15:33:59 -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 1rSjwb-0003Le-Lf for bug-gnu-emacs@gnu.org; Wed, 24 Jan 2024 15:33: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 1rSjwb-0006Ty-DE for bug-gnu-emacs@gnu.org; Wed, 24 Jan 2024 15:33:57 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rSjwg-00032Y-Jw for bug-gnu-emacs@gnu.org; Wed, 24 Jan 2024 15:34:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 24 Jan 2024 20:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 68698 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.170612839611583 (code B ref -1); Wed, 24 Jan 2024 20:34:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 24 Jan 2024 20:33:16 +0000 Original-Received: from localhost ([127.0.0.1]:46695 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rSjvw-00030l-39 for submit@debbugs.gnu.org; Wed, 24 Jan 2024 15:33:16 -0500 Original-Received: from lists.gnu.org ([2001:470:142::17]:41756) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rSjvu-00030M-0L for submit@debbugs.gnu.org; Wed, 24 Jan 2024 15:33:14 -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 1rSjvi-0002sb-C7 for bug-gnu-emacs@gnu.org; Wed, 24 Jan 2024 15:33:02 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rSjvg-0006MF-5C for bug-gnu-emacs@gnu.org; Wed, 24 Jan 2024 15:33:01 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id B655F10007D for ; Wed, 24 Jan 2024 15:32:58 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1706128377; bh=EP+r4wFH0r8wzH646aKpYZxlJF6bf319kXKLV9S3F4g=; h=From:To:Subject:Date:From; b=BNoJ4xEren8An9hq/znHzZwdlb3B+S6Dfdf9+VTY/zvjA8VbWHpobueLKpzAR0oiH CZ1M8w4BQvTaAoVuhsoLoK7352tiuHsObrtp48pttMEY7DNmWWbtISoSAOOv+CRYiI TjBnEXcxxzNufcaD5IEc9BSFVfr19lUeSjKWA78DtxjfzfmCCHcrPZXpmy7LEPuWsl 2Lkbhl8VeecNFcQKsQX9zR1VbyUDv1qN69R4to5jd2HuJNe6VeMRAsjsZmEJ/Ss3Cm ArMI7qsVxyFURezKEDo3WTrvxJFSakDm1cvASpdaPVn4NGRZt88C3QJy6mU4wQyva3 xZzXWCdBG7gig== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id AA1B810001D for ; Wed, 24 Jan 2024 15:32:57 -0500 (EST) Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 9D962120BF6 for ; Wed, 24 Jan 2024 15:32:57 -0500 (EST) Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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:278819 Archived-At: --=-=-= Content-Type: text/plain 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. 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=xtmouse.patch 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) --=-=-=--