bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#68698: 30.0.50; Making xt-mouse emit `wheel-up/down`


From: Jared Finder
Subject: bug#68698: 30.0.50; Making xt-mouse emit `wheel-up/down`
Date: Thu, 25 Jan 2024 17:41:20 -0800

On 2024-01-24 23:30, Eli Zaretskii wrote:
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" <bug-gnu-emacs@gnu.org>

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.

I'll be so happy if everything switches over to mouse-up / mouse-down events. This would be great. I'd love to ignore mouse-wheel-down-event and mouse-wheel-down-alternate-event.

diff --git a/lisp/mwheel.el b/lisp/mwheel.el
@@ -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")

I think there is a bug with mouse-wheel-up/down/left/right-event and alternate event where it doesn't take window-system into account. Without fixing that bug, this won't work because it is valid for mouse-wheel-up-event to be wheel-down in a terminal. A local run of HEAD (as of Jan 17, I'm at daec3e) with "./configure --with-pgtk" has mouse-wheel-up-event set to wheel-down because (featurep 'pgtk-win) is t, even with -nw on the command line. Testing on Windows at Emacs 29.1 shows the same behavior.

Also, I do not think xt-mouse knows how to generate mouse-6 or mouse-7 events. I think to generate events beyond mouse-5, you need to test against the 128 bit as well. I don't have mouse hardware to confirm this behavior.

  -- MJF





reply via email to

[Prev in Thread] Current Thread [Next in Thread]