GNU Screen weird characters on click

gnu-screenttyxterm

I have a small problem in GNU screen. A GNU screen session runs on my RaspberryPi. Now sometimes, when I join it, if I click in the terminal (I'm using terminator on Fedora) I see weird characters written. These characters depend on the coordinates of my mouse… Seems like a wrong decoding of the click event sent to GNU Screen.
These characters include things like

kM#kM -  Z3#Z3  -  q-#q-

etc…

I first thought it was a problem with my tty so I went and opened a new GNU Screen session on my RaspberryPi: no problem at all.
I did a stty -a on both session and saw there were difference. I then did a stty -g > ~/stty-good-settings on the good session and loaded it on the bad one with stty `cat ~/stty-good-settings` (I compared the values after that, the settings were successfully loaded) but I still have the problem in one of the screen sessions and not the other!

I'm not sure what's happening, if this is due to my TERM value (same in both), my tty settings, my terminal…

Best Answer

Something that runs inside GNU screen decided it was running in an xterm (or similar) instead and enabled Application Mouse mode. (Or something you run in that terminal before you attached to GNU screen, possibly even before ssh, which did not properly reset itself.) This is often the case if $TERM is not “screen” but e.g. “xterm” or “screen.xterm”. The latter is seen on Debian systems (and derivates) that have ncurses-term installed; try purging that package (on host and raspi).

Otherwise, reset (as was already said) or printf \\x033c may help temporarily. Or, of course, the proper escape sequences to tell your terminal emulator to disable mouse mode.

Related Question