diff options
author | nicm <nicm> | 2014-06-19 07:26:43 +0000 |
---|---|---|
committer | nicm <nicm> | 2014-06-19 07:26:43 +0000 |
commit | a94696defa108dcddc39d50596e69266e595eb74 (patch) | |
tree | 76d2e3b15758c83a0d81738f4a3b871ea6cf5fda | |
parent | 21ade85f24c122ecc3148a3bfeed3044a59c3214 (diff) |
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.
-rw-r--r-- | tty-keys.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -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) |