From 2756d127507cb939582adf2bbaf7be4cf5b711cd Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 10 Oct 2013 11:49:42 +0000 Subject: Handle input mouse positions <33 (we already can generate them). --- tty-keys.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'tty-keys.c') diff --git a/tty-keys.c b/tty-keys.c index 26edbf32..3b652db8 100644 --- a/tty-keys.c +++ b/tty-keys.c @@ -676,11 +676,17 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size) log_debug("mouse input: %.*s", (int) *size, buf); /* Check and return the mouse input. */ - if (b < 32 || x < 33 || y < 33) + if (b < 32) return (-1); b -= 32; - x -= 33; - y -= 33; + if (x >= 33) + x -= 33; + else + x = 256 - x; + if (y >= 33) + y -= 33; + else + y = 256 - y; } else if (buf[2] == '<') { /* Read the three inputs. */ *size = 3; -- cgit From 784b711393f99523482515d7e6d0114f96f2ecec Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 10 Oct 2013 11:57:52 +0000 Subject: Assign mouse x/y coords before checking them. When receiving mouse inputs, we should set the x/y coordinates earlier than we currently do, so that we aren't off-by-one in the case when the statusbar is at the top of the screen. By Thomas Adam. --- tty-keys.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tty-keys.c') diff --git a/tty-keys.c b/tty-keys.c index 3b652db8..7de5ce59 100644 --- a/tty-keys.c +++ b/tty-keys.c @@ -746,6 +746,8 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size) m->sgr = sgr; m->sgr_xb = sgr_b; m->sgr_rel = sgr_rel; + m->x = x; + m->y = y; if (b & 64) { /* wheel button */ b &= 3; if (b == 0) @@ -773,8 +775,6 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size) } m->button = (b & 3); } - m->x = x; - m->y = y; return (0); } -- cgit