GNU bug report logs - #50321
28.0.50; feature/pgtk: cannot scroll with xterm-mouse-mode

Previous Next

Package: emacs;

Reported by: Henri Menke <henri <at> henrimenke.de>

Date: Wed, 1 Sep 2021 15:27:03 UTC

Severity: normal

Found in version 28.0.50

Done: Yuuki Harano <masm+emacs <at> masm11.me>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 50321 in the body.
You can then email your comments to 50321 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#50321; Package emacs. (Wed, 01 Sep 2021 15:27:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Henri Menke <henri <at> henrimenke.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 01 Sep 2021 15:27:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Henri Menke <henri <at> henrimenke.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; feature/pgtk: cannot scroll with xterm-mouse-mode
Date: Wed, 01 Sep 2021 09:28:24 +0200
The easiest reproducer is to launch Emacs like this and then scroll
using the mouse wheel

   $ emacs -Q
   $ emacs -nw -Q --eval '(xterm-mouse-mode t)'

It works fine in GUI Emacs but terminal Emacs will report

   <mouse-5> is undefined
   <mouse-4> is undefined

This is due to


https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/mwheel.el?h=feature/pgtk&id=13a9a5e836cbe6e64aadaba40fe1f7eb83320d08#n53

which unconditionally maps the scroll events to `'wheel-up` and
`'wheel-down` when `pgtk` is active.

A quick fix would be something like

   $ emacs -nw -Q --load test.el

with

   ;; test.el
   (unless window-system
     (xterm-mouse-mode t)
     (when (featurep 'pgtk)
       (setq mouse-wheel-down-event 'mouse-4)
       (setq mouse-wheel-up-event 'mouse-5)
       (global-set-key (kbd "<mouse-4>") 'mwheel-scroll)
       (global-set-key (kbd "<mouse-5>") 'mwheel-scroll)))

Unfortuantely, it is not as simple because the user could have Emacs
running as a daemon, connecting with both GUI and terminal clients in
which case one of them won't work. In fact, using the above command to
start a daemon and then connecting with a GUI client will cause `Bad
binding in mwheel-scroll` upon scrolling.

I tried fixing this by changing `mouse-wheel-(down|up)-event` in
`focus-in-hook` depending on the `(window-system (selected-frame))` but
this crashes Emacs with segmentation fault upon switching between
frames.

   ;; test.el
   (when (featurep 'pgtk)
     (add-hook 'focus-in-hook
               (lambda ()
                 (if (window-system (selected-frame))
                     (setq mouse-wheel-down-event 'mouse-4
   			mouse-wheel-up-event 'mouse-5)
                   (setq mouse-wheel-down-event 'wheel-up
                         mouse-wheel-up-event 'wheel-down)))))
   (unless window-system
     (xterm-mouse-mode t)
     (when (featurep 'pgtk)
       (setq mouse-wheel-down-event 'mouse-4)
       (setq mouse-wheel-up-event 'mouse-5)
       (global-set-key (kbd "<mouse-4>") 'mwheel-scroll)
       (global-set-key (kbd "<mouse-5>") 'mwheel-scroll)
       (global-set-key (kbd "<C-mouse-4>") 'mouse-wheel-text-scale)
       (global-set-key (kbd "<C-mouse-5>") 'mouse-wheel-text-scale)
       (global-set-key (kbd "<S-mouse-4>") 'mwheel-scroll)
       (global-set-key (kbd "<S-mouse-5>") 'mwheel-scroll)))

Related thread on Emacs Stack Exchange:
https://emacs.stackexchange.com/questions/64935/mwheel-scroll-bindings-between-gui-and-terminal

;;===================
In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.27, cairo version 1.16.0)
Repository revision: 74d017edb6717ad76d38edc02ad3210d4ad66b96
Repository branch: nixos-21.05
Windowing system distributor 'System Description: NixOS 21.05 (Okapi)

Configured using:
 'configure
 --prefix=/nix/store/p2yxdx48mqgvaflygysqz5b7p7q2bbpw-emacs-pgtkgcc-20210725.0
 --disable-build-details --with-modules --with-x-toolkit=gtk3
 --with-cairo --with-native-compilation --with-pgtk'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY
PDUMPER PGTK PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS XIM
GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50321; Package emacs. (Tue, 16 Nov 2021 16:10:02 GMT) Full text and rfc822 format available.

Message #8 received at 50321 <at> debbugs.gnu.org (full text, mbox):

From: Yuuki Harano <masm+emacs <at> masm11.me>
To: henri <at> henrimenke.de
Cc: 50321 <at> debbugs.gnu.org
Subject: Re: bug#50321: 28.0.50; feature/pgtk: cannot scroll with
 xterm-mouse-mode
Date: Wed, 17 Nov 2021 01:09:38 +0900 (JST)
I tried to fix the issue on feature/pgtk.
I supported both "mouse-4"-type and "wheel-up"-type.

Please try it.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50321; Package emacs. (Wed, 17 Nov 2021 08:57:01 GMT) Full text and rfc822 format available.

Message #11 received at 50321 <at> debbugs.gnu.org (full text, mbox):

From: Henri Menke <henri <at> henrimenke.de>
To: Yuuki Harano <masm+emacs <at> masm11.me>
Cc: 50321 <at> debbugs.gnu.org
Subject: Re: bug#50321: 28.0.50; feature/pgtk: cannot scroll with
 xterm-mouse-mode
Date: Wed, 17 Nov 2021 09:56:20 +0100
I can confirm that this fixes the issue.
Thank you very much!

Kind regards,
Henri

On Wed, 2021-11-17 at 01:09 +0900, Yuuki Harano wrote:
> I tried to fix the issue on feature/pgtk.
> I supported both "mouse-4"-type and "wheel-up"-type.
> 
> Please try it.






Reply sent to Yuuki Harano <masm+emacs <at> masm11.me>:
You have taken responsibility. (Sun, 21 Nov 2021 15:02:01 GMT) Full text and rfc822 format available.

Notification sent to Henri Menke <henri <at> henrimenke.de>:
bug acknowledged by developer. (Sun, 21 Nov 2021 15:02:02 GMT) Full text and rfc822 format available.

Message #16 received at 50321-done <at> debbugs.gnu.org (full text, mbox):

From: Yuuki Harano <masm+emacs <at> masm11.me>
To: 50321-done <at> debbugs.gnu.org
Subject: Re: bug#50321: 28.0.50; feature/pgtk: cannot scroll with
 xterm-mouse-mode
Date: Mon, 22 Nov 2021 00:01:33 +0900 (JST)



bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 20 Dec 2021 12:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 121 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.