Bug 285984 - Support extended mouse coordinates
Summary: Support extended mouse coordinates
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: 2.4.5
Platform: Ubuntu Linux
: NOR wishlist
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-07 11:59 UTC by Egmont Koblinger
Modified: 2012-04-20 05:44 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.9.0
Sentry Crash Report:


Attachments
Proposed patch (3.91 KB, patch)
2011-11-07 19:07 UTC, Egmont Koblinger
Details
updated to current git head (4.51 KB, patch)
2012-01-20 23:26 UTC, Egmont Koblinger
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Egmont Koblinger 2011-11-07 11:59:43 UTC
Version:           2.4.5 (using KDE 4.4.5) 
OS:                Linux

Using the legacy method, mouse coordinates can be reported only up to 223. If you have a wider terminal, you cannot use the mouse in the rightmost columns.

There exist two extensions to overcome this problem, a broken one invented by xterm (the "DEC 1005" mode) which is supported by xterm, urxvt and iterm2; and a good one invented by urxvt (the "DEC 1015" mode), supported by urxvt and iterm2.

Please see the http://www.midnight-commander.org/ticket/2662 for a detailed introduction and comparison of the two extensions, for a patch to midnight commander to support the urxvt extension, and for xterm to support this extension. Also please see http://bugzilla.gnome.org/show_bug.cgi?id=662423 for a patch to gnome-terminal (vte) to add support for both extensions.

Please add support for these two extensions (or at least the good "urxvt 1015" extension) to Konsole, too. Based on the similar patches for other terminals, it should be very easy to do it.

Reproducible: Always

Steps to Reproduce:
Compile mc-4.8.0 with the patch at the site linked above. Start it, and make the terminal wider than 223 columns. Try to use mouse in the rightmost columns.

Actual Results:  
Mouse click coordinates get mangled, i.e. the application believes you clicked somewhere else than you actually did. E.g. you click on "10 Quit" in the bottom right corner, but MC brings up the User menu instead.

Expected Results:  
Mouse should work perfectly everywhere, even in columns beyond 223.

Technical details at http://www.midnight-commander.org/ticket/2662
Comment 1 Egmont Koblinger 2011-11-07 19:07:56 UTC
Created attachment 65364 [details]
Proposed patch

Please see the proposed patch.

It was made against a bit older KDE which I could compile, but it applies cleanly to the newest konsole, so I guess that one works too.
Comment 2 Egmont Koblinger 2011-11-08 08:48:14 UTC
(Note that my patch slightly changes the behavior with the legacy escape sequences: clicking beyond 223 used to send erroneus codes, now it doesn't send anything. I think the new behavior is better.)
Comment 3 Duncan 2011-12-23 18:31:46 UTC
This can be very useful for mc users on widescreens and when the konsole window is expanded across multiple monitors.  Please merge. =:^)
Comment 4 Egmont Koblinger 2012-01-17 10:34:36 UTC
FYI: as of now, the urxvt extension is supported by at least the following

applications:
- vim >= 7.3.343 (configure --with-features=big; echo ":set ttymouse=urxvt" >>.vimrc)
- mc >= 4.8.1 (out of the box, no config needed)

and terminals:
- rxvt-unicode >= 9.10
- xterm >= 277
- vte (gnome-terminal etc.) >= 0.31
- iterm2 (for mac os x)

It would be nice to see konsole in the list too.
Comment 5 Kurt Hindenburg 2012-01-20 16:17:03 UTC
The konsole patch w/ the git master of mc didn't seem to work.  After the konsole patch, the mouse clicks didn't work anywhere.

I'll look at it later.
Comment 6 Egmont Koblinger 2012-01-20 19:44:53 UTC
Hi Kurt, I'm sorry to hear that the patch didn't work for you. Could you please help me find what went wrong?

Could you try your mc with any of these terminals to see if it works: xterm >= 277, rxvt-unicode >= 9.10, or vte >= 0.31 ?

Instead of mc, could you try vim 7.3 with all the patches from ftp://ftp.vim.org/pub/vim/patches/7.3/ applied in order, ./configure --with-features=big, and having these in your .vimrc:
:set mouse=a
:set ttymouse=urxvt

Could you please try this in your patched konsole and tell what it prints?
$ echo $'\e[?1002h\e[?1015h'; cat
and now click at random places on the screen...

What version of konsole are you compiling?

Thanks a lot for your help!
Comment 7 Egmont Koblinger 2012-01-20 22:47:59 UTC
I've managed to compile konsole-4.7.4 (latest release) and git HEAD (cabce6ae89b5939ad77b3b8202170e7badee7ceb).

4.7.4: The patch applies and still works for me.

HEAD: There were some changes in the code which broke mouse handling at the first place, you cannot click beyond column 95. (I guess it has something to do with the escape sequence not being valid UTF-8 in that case.) The patch doesn't apply so I couldn't test.
Comment 8 Egmont Koblinger 2012-01-20 23:26:42 UTC
Created attachment 68058 [details]
updated to current git head
Comment 9 Egmont Koblinger 2012-01-20 23:28:48 UTC
I've added a new patch for your convenience. It reverts the change that broke mouse beyond column 95 (5143f39), adds comments, and updates indentation of the code. Other than that, it's the same as the previous.

Please test it, I'm eager to hear if it works for you.
Comment 10 Kurt Hindenburg 2012-01-21 04:07:47 UTC
Thanks for the patch - I should have realized a previous commit broke the mouse clicks.

Looks good so far.
Comment 11 Kurt Hindenburg 2012-01-21 18:25:50 UTC
Git commit b876f2a3edcb63f29588fdde6b20dc6c9d13bc24 by Kurt Hindenburg.
Committed on 21/01/2012 at 19:21.
Pushed by hindenburg into branch 'master'.

Support extended mouse coordinates.

Using the legacy method, mouse coordinates can be reported only up to 223. If
you have a wider terminal, you cannot use the mouse in the rightmost columns.

There exist two extensions to overcome this problem, a broken one invented by
xterm (the "DEC 1005" mode) which is supported by xterm, urxvt and iterm2; and
a good one invented by urxvt (the "DEC 1015" mode), supported by urxvt and
iterm2.

Many thanks to Egmont Koblinger egmont@gmail.com for report and patch.
FIXED-IN: 4.9

M  +32   -2    src/Vt102Emulation.cpp
M  +6    -4    src/Vt102Emulation.h

http://commits.kde.org/konsole/b876f2a3edcb63f29588fdde6b20dc6c9d13bc24