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.
pull/1/head
nicm 2014-06-19 07:26:43 +00:00
parent 21ade85f24
commit a94696defa
1 changed files with 19 additions and 0 deletions

View File

@ -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)