From dccdf5ff4286ce22b32c18513b3ae53288fcfb5f Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 10 Apr 2021 13:36:35 +0200 Subject: Add tests for mouse events MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libterminput.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'libterminput.c') diff --git a/libterminput.c b/libterminput.c index 960967d..5758be0 100644 --- a/libterminput.c +++ b/libterminput.c @@ -6,6 +6,7 @@ #include #include #include +#include struct input { @@ -330,7 +331,7 @@ parse_sequence(union libterminput_input *input, struct libterminput_state *ctx) case 'M': if (ctx->flags & LIBTERMINPUT_MACRO_ON_CSI_M) { input->keypress.key = LIBTERMINPUT_MACRO; - } else if (nnums >= 3) { /* TODO test */ + } else if (nnums >= 3) { /* Parsing for \e[?1000;1015h output. */ nums[0] -= 32ULL; decimal_mouse_tracking_set_press: @@ -338,15 +339,17 @@ parse_sequence(union libterminput_input *input, struct libterminput_state *ctx) decimal_mouse_tracking: input->mouseevent.type = LIBTERMINPUT_MOUSEEVENT; input->mouseevent.x = (size_t)nums[1] + (size_t)!nums[1]; - input->mouseevent.y = (size_t)nums[2] + (size_t)!nums[3]; + input->mouseevent.y = (size_t)nums[2] + (size_t)!nums[2]; input->mouseevent.mods = (enum libterminput_mod)((nums[0] >> 2) & 7ULL); if (nums[0] & 32) input->mouseevent.event = LIBTERMINPUT_MOTION; nums[0] = (nums[0] & 3ULL) | ((nums[0] >> 4) & ~3ULL); if (nums[0] < 4) { nums[0] = (nums[0] + 1) & 3; - if (!nums[0] && input->mouseevent.event == LIBTERMINPUT_PRESS) + if (!nums[0] && input->mouseevent.event == LIBTERMINPUT_PRESS) { input->mouseevent.event = LIBTERMINPUT_RELEASE; + nums[0] = 1; + } } input->mouseevent.button = (enum libterminput_button)nums[0]; } else if (!nnums & !(ctx->flags & LIBTERMINPUT_DECSET_1005)) { /* TODO test */ @@ -579,7 +582,7 @@ parse_sequence(union libterminput_input *input, struct libterminput_state *ctx) case 'D': input->keypress.key = LIBTERMINPUT_F4; break; case 'E': input->keypress.key = LIBTERMINPUT_F5; break; default: - if (ctx->key[1] == '<' && (ctx->key[2] == 'M' || ctx->key[2] == 'm') && nnums >= 3) { /* TODO test */ + if (ctx->key[1] == '<' && (ctx->key[2] == 'M' || ctx->key[2] == 'm') && nnums >= 3) { /* Parsing for \e[?1003;1006h output. */ input->mouseevent.event = LIBTERMINPUT_PRESS; if (ctx->key[2] == 'm') -- cgit v1.2.3-70-g09d2