Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: one time in 20 error

On Wed, Nov 30, 2022 at 2:57 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
> I can press and hold the button, wait for the program to end (so far mouse
> clicks always make a selection from a list and return) and then release the
> button and, again, maybe one time in 20 I'll get the bogey.  I've tried
> variation on click speed but nothing  makes it better or worse.   You don't
> suppose it could be a mechanical issue with the mouse?  You know how they
> sometimes get sticky and mouse clicks are poorly registered?  I've had mice
> that tended to return two clicks when only one was made.  A mechanically
> unclean release seems to confuse the computer.

What happens is that you click while the script is running and
listening to mouse events, this causes the terminal to send you data,
which can take arbitrary long to arrive to your script's stdin. Then
the script deactivates mouse tracking and exists, and then the data
from the past click reaches stdin. Clicks after the script exits won't
generate any data because mouse tracking is already disabled.

> Well, so far the 'timeout' is working 100%

It won't work if you run your script over SSH with high latency.
Moreover, it adds lag every time the script exists. A better solution
is what I posted above. It doesn't add more latency than necessary and
will correctly clear stdin with any amount of latency between your
script and the terminal. The code I posted needs to be run when the
script ends. If your script disables mouse tracking on its own, you
can remove the first two `print` statements from my code snippet.


Messages sorted by: Reverse Date, Date, Thread, Author