cosmos72 / twin

Text mode window environment. A "retro" program for embedded or remote systems, that doubles as X11 terminal and text-mode equivalent of VNC server
Other
661 stars 39 forks source link

xterm mouse support: only 223 chars wide? #72

Closed jafcobend closed 2 years ago

jafcobend commented 2 years ago

Using twin --hw=tty in xterm over an SSH connection to a remote machine (twin on the remote side) it seems that the mouse stops working at about 223 chars from the left. I don't have this problem with hw_X11 on the local system. Is this an issue with the xterm/gpm mouse protocol? Or something broken in twin?

cosmos72 commented 2 years ago

It makes sense. Basic xterm mouse protocol uses a single byte >= 32 to represent each coordinate, so it's limited to approx 255-32 = 223 in both maximum x and maximum y. Honestly, I don't know if xterm also supports some more advanced mouse protocol with higher limits.

jafcobend commented 2 years ago

OK. That makes sense then. It doesn't appear gpm has the same issue. Running on a native Linux console at full HD res I can use the mouse out 230+ chars. I suppose that's why it surprised me. I'm not sure how many others would do something like this. ;-) Thanks for the info.

cosmos72 commented 2 years ago

Update: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking states that xterm also supports an extended mouse protocol with maximum height and width = 2095. I will have a look

jafcobend commented 2 years ago

SWEET! I'll have to read up on that. I don't suppose it has scroll-wheel support? TWIN has become my replacement for tmux and screen. Being able to expand my session window to cover one or both my HD monitors is sometimes very useful. 8-)

cosmos72 commented 2 years ago

Probably yes - scroll wheel is usually treated as two additional buttons.

cosmos72 commented 2 years ago

I have implemented both in commit e91ef2283ff982b2823949057e73dfdfad0d4b0e:

server/hw/hw_tty: improve mouse support on xterm-like terminals

  • add support for mouse scroll wheel
  • use enhanced xterm mouse protocol ESC [?1002h ESC [?1006h to support mouse positions > 223 (both in x and y)

fixes #72

jafcobend commented 2 years ago

Sweet! Thanks! I'm pulling them down now and will start the baking process. I'm working on some mail logs on a remote server so the extra width will be REALLY nice!

jafcobend commented 2 years ago

BINGO It works! Now I need to try it some other terminal environment to see if anything got broken....

jafcobend commented 2 years ago

Scroll wheel works through xterm too!

cosmos72 commented 2 years ago

Just for information, a setup that always works perfectly is: Run twin locally (typically with --hw=X or --hw=xft) Open a terminal inside twin and ssh to a remote host; In the remote host, run twin --hw=tty

jafcobend commented 2 years ago

Just for information, a setup that always works perfectly is: Run twin locally (typically with --hw=X or --hw=xft)

Not really. It has catastrophic failures. I'll have to play with it a bit more. But at minimum with --hw=X11 locally when the remote session closes the menu bar goes away and the keyboard becomes inoperable. Then the local TWIN has to be closed to work again.

As I said I'll have to play with it more to quantify exactly what's going wrong and what the specific symptoms are. But that was my initial impression. Right now xterm to a remote TWIN works well... unless you're reestablishing a disconnected session. I'll have to play with that a bit more too...

cosmos72 commented 2 years ago

This is really strange, as it's a configuration that I use often. If you can investigate it further, I'd really appreciate that (please open a separate issue when you report what you found)

jafcobend commented 2 years ago

I can't get it to break again. Maybe getting all of my installs up to the latest version helped. Or maybe it was a slightly different manifestation of a bug I've just started seeing in the combination of X server, power management and xscreensaver in this new OS upgrade I just started using. But if I stumble into it again I'll make sure to poke at it more, quantify it and open an issue. :-D