=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/tty-keys.c,v retrieving revision 1.66 retrieving revision 1.67 diff -u -r1.66 -r1.67 --- src/usr.bin/tmux/tty-keys.c 2014/05/08 07:54:47 1.66 +++ src/usr.bin/tmux/tty-keys.c 2014/06/19 07:26:43 1.67 @@ -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 @@ -475,6 +475,8 @@ 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 @@ 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. */ @@ -729,6 +739,15 @@ y--; 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;