mintty / wsltty

Mintty as a terminal for Bash on Ubuntu on Windows / WSL
Other
3.12k stars 104 forks source link

mouse's first 'single left click' not sent unless another intention is performed (click-and-drag) #288

Closed YAMLcase closed 3 years ago

YAMLcase commented 3 years ago

wsltty doesn't seem to send a 'single left click' mouse event when switching focus back from another app, yet it does send the first click when the intent is 'left click and drag'. I noticed the behavior while using tmux as I am very used to switching between terminal and other apps like chrome.

visidata (https://github.com/saulpw/visidata) is the application I used to verify several conditions because it shows what mouse events it detects (if you have another tool for debugging mouse events I'd like to have it)

image

behaviors:

mintty commented 3 years ago

That is on purpose because the use case is to set focus to a window and not position the actual cursor at the same time. When clicking "into" a window rather than "within" a window users do not normally target the mouse precisely but just want to raise the window again. This bears the risk that the cursor position is accidentally set to a place that is not intended. In a text editor or a file manager that may be confusing at best. "It's a feature, not a bug."

YAMLcase commented 3 years ago

Ahh ok this makes sense. Would it be feasible to turn this into a feature request to add an option for toggling the behavior? Another option I can live with is single right click on focus behaves like a single left click.

FYI in case you're curious where my muscle memory was trained, I'm coming from Windows Terminal.

mintty commented 3 years ago

Actually, if your application activates mouse reporting mode AND also focus reporting (DESCET 1004, ESC [ ? 1 0 0 4 h), initial clicks will be reported, based on the assumption that the application can recognize itself what's happening in this case. This was tuned in the course of mintty/mintty#717 and #88 and should provide sufficient flexibility, so I'd rather refrain from adding more complexity.

YAMLcase commented 3 years ago

Actually, if your application activates mouse reporting mode AND also focus reporting

by application, do you mean tmux and visidata in my examples?

YAMLcase commented 3 years ago

I read through tmux's man page and found:

https://man7.org/linux/man-pages/man1/tmux.1.html#OPTIONS

focus-events [on | off]
             When enabled, focus events are requested from the terminal
             if supported and passed through to applications running in
             tmux.  Attached clients should be detached and attached
             again after changing this option.

This fixes my problem. Thanks @mintty for sending me in the right direction!