mirror of
https://github.com/tmate-io/tmate.git
synced 2025-03-08 12:12:18 +01:00
Some terminals send spurious releases for mouse wheel in SGR mouse mode,
this causes confusion when tmux uses SGR outside but the application inside tmux is using conventional xterm mouse reporting. So suppress obviously bad input. From Timothy Allen, SF bug 128.
This commit is contained in:
parent
21ade85f24
commit
a94696defa
19
tty-keys.c
19
tty-keys.c
@ -475,6 +475,8 @@ tty_keys_next(struct tty *tty)
|
||||
goto complete_key;
|
||||
case -1: /* no, or not valid */
|
||||
break;
|
||||
case -2: /* yes, but we don't care. */
|
||||
goto discard_key;
|
||||
case 1: /* partial */
|
||||
goto partial_key;
|
||||
}
|
||||
@ -586,6 +588,14 @@ complete_key:
|
||||
server_client_handle_key(tty->client, key);
|
||||
|
||||
return (1);
|
||||
|
||||
discard_key:
|
||||
log_debug("discard key %.*s %#x", (int) size, buf, key);
|
||||
|
||||
/* Remove data from buffer. */
|
||||
evbuffer_drain(tty->event->input, size);
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* Key timer callback. */
|
||||
@ -730,6 +740,15 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size)
|
||||
sgr = 1;
|
||||
sgr_rel = (c == 'm');
|
||||
|
||||
/*
|
||||
* Some terminals (like PuTTY 0.63) mistakenly send
|
||||
* button-release events for scroll-wheel button-press event.
|
||||
* Discard it before it reaches any program running inside
|
||||
* tmux.
|
||||
*/
|
||||
if (sgr_rel && (sgr_b & 64))
|
||||
return (-2);
|
||||
|
||||
/* Figure out what b would be in old format. */
|
||||
b = sgr_b;
|
||||
if (sgr_rel)
|
||||
|
Loading…
Reference in New Issue
Block a user