Subject: Re: bug#49803: 27.2; Mouse wheel on MacOS is reported as mouse-4 and mouse-5, but Emacs mwheel seems to use wheel-up/wheel-down instead

From: Robert Pluim <[email-masked]>
Date: Wed, 11 Aug 2021 16:59:45 +0200

>>>>> On Wed, 11 Aug 2021 15:03:01 +0300, Eli Zaretskii <[email-masked]> said:

    >> From: Robert Pluim <[email-masked]>
    >> Cc: [email-masked],  [email-masked]
    >> Date: Wed, 11 Aug 2021 11:24:54 +0200
    >> 
    >> I was unclear: I hadn't figured out how to get the relevant terminal
    >> programs to generate either wheel-up/down or mouse-4/5. It looks like
    >> iterm2 sends mouse events using the xterm protocol, which xt-mouse
    >> then posts as mouse-4/5 events. I guess we could modify xt-mouse to
    >> optionally send them as wheel-up/down instead, but that feels like a hack.

    Eli> Does the xterm protocol allow to report wheel events, or does it only
    Eli> allow to report mouse-click events?  If the latter, I don't see how
    Eli> you could map the events in any way different from what we have now,
    Eli> i.e. via a user-controlled setting.

It allows reporting wheel events, but as that part of the protocol is
not being used by the iterm2 everything is reported as mouse clicks,
but thatʼs immaterial:

- terminal sends "\e[<" to indicate itʼs sending us a mouse event
- xt-mouse.el reads and decodes a bunch of stuff from the terminal
- xt-mouse.el produces a 'mouse-<n>' event from that bunch of stuff, and
  pushes it onto 'unread-command-events'

So the only place I can see to add the optional mapping is in xt-mouse.el
itself, or in 'read-char' in keyboard.c

Itʼs easier to do in xt-mouse.el, and as far as I can tell thatʼs the
only terminal mouse handling code that does this kind of thing (GPM is
handled in keyboard.c)

Robert
--