summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/tty-keys.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2014-06-19 07:26:43 +0000
committernicm <nicm@openbsd.org>2014-06-19 07:26:43 +0000
commit9146dae2cd267c558643d5a89f3202b66685e65b (patch)
tree16ae5bf67638ce12ebd3a2a95474ef13c6b52924 /usr.bin/tmux/tty-keys.c
parentdrm/i915: fix lane bandwidth capping for DP 1.2 sinks (diff)
downloadwireguard-openbsd-9146dae2cd267c558643d5a89f3202b66685e65b.tar.xz
wireguard-openbsd-9146dae2cd267c558643d5a89f3202b66685e65b.zip
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.
Diffstat (limited to 'usr.bin/tmux/tty-keys.c')
-rw-r--r--usr.bin/tmux/tty-keys.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/usr.bin/tmux/tty-keys.c b/usr.bin/tmux/tty-keys.c
index 2515c60d377..067e3f6a91f 100644
--- a/usr.bin/tmux/tty-keys.c
+++ b/usr.bin/tmux/tty-keys.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty-keys.c,v 1.66 2014/05/08 07:54:47 nicm Exp $ */
+/* $OpenBSD: tty-keys.c,v 1.67 2014/06/19 07:26:43 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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)