Bug 302731 - emacs xterm-mouse-mode doesn't work in Konsole
Summary: emacs xterm-mouse-mode doesn't work in Konsole
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: emulation (show other bugs)
Version: 2.7.4
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords: reproducible
Depends on:
Blocks:
 
Reported: 2012-06-29 08:23 UTC by Peter Eisentraut
Modified: 2021-06-07 18:39 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 21.08


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Eisentraut 2012-06-29 08:23:18 UTC
In GNU Emacs in xterm-mouse-mode, dragging the mouse inserts some control sequences like

[[[[M[[[[[M *'[M *'M *'[M )'M )'M ('[M ''M &' %'M $'M #'[M "'M ,'[M -'[M[M -' -'

instead of selecting a region.  This works correctly in xterm and gnome-terminal, so it could be some difference in terminal emulation.

The file etc/PROBLEMS in the emacs distribution contains this:

"""
*** Gnome: Emacs' xterm-mouse-mode doesn't work on the Gnome terminal.

A symptom of this bug is that double-clicks insert a control sequence
into the buffer.  The reason this happens is an apparent
incompatibility of the Gnome terminal with Xterm, which also affects
other programs using the Xterm mouse interface.  A problem report has
been filed.
"""

It looks like this was actually fixed in Gnome, but at least it indicates that they consider xterm-mouse-mode to work correctly and see the problems in the terminal emulators.

Reproducible: Always

Steps to Reproduce:
1. start emacs -Q -nw test.txt
2. M-x xterm-mouse-mode
3. drag the mouse around (click, hold, and move)
Actual Results:  
crazy control sequences are inserted

Expected Results:  
a region should be selected (compare with xterm or gnome-terminal)
Comment 1 Jekyll Wu 2012-06-30 08:06:23 UTC
Thanks for reporting.
Comment 2 Egmont Koblinger 2012-08-06 20:03:13 UTC
Same with konsole-2.8.4 (kde-4.8.4).

Emacs only turns on the simple mouse mode without dragging reporting (1000), not the dragging reporting extended one (1002). Most terminal emulators, including xterm and gnome-terminal, really only send events at mouse press and release in this case. Konsole, however, keeps sending click events whenever the mouse is dragged. I believe this confuses emacs (although it shouldn't). So I'd say both emacs and konsole are guilty. Emacs should be tolerant against this input, but konsole shouldn't send click events on mouse drag either.

If you enable the extended, dragging reporting mode prior to starting emacs:
echo -n $'\e[?1002h'
then emacs of course doesn't understand the dragging events and prints some warnings about them, but starts behaving relatively sanely.
Comment 3 tcanabrava 2021-06-07 18:04:49 UTC
Git commit 027e8c150c45ad1821d828ea93545a36f7b0a5f3 by Tomaz  Canabrava, on behalf of Luis Javier Merino Morán.
Committed on 07/06/2021 at 18:03.
Pushed by tcanabrava into branch 'master'.

Don't send move events for normal mouse tracking

xterm's DECSET 1000 requests justs press and release notifications, so
do not send move events on this mode.

M  +5    -0    src/Vt102Emulation.cpp

https://invent.kde.org/utilities/konsole/commit/027e8c150c45ad1821d828ea93545a36f7b0a5f3