From 24ebd3c309c5d6cad63bbf1b40de8c17aead0366 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 19 Feb 2025 23:06:02 +0100 Subject: Add state marshalling and unmarshalling functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libterminput_unmarshal_mouseevent__.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 libterminput_unmarshal_mouseevent__.c (limited to 'libterminput_unmarshal_mouseevent__.c') diff --git a/libterminput_unmarshal_mouseevent__.c b/libterminput_unmarshal_mouseevent__.c new file mode 100644 index 0000000..55f72ea --- /dev/null +++ b/libterminput_unmarshal_mouseevent__.c @@ -0,0 +1,23 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" + + +int +libterminput_unmarshal_mouseevent__(struct libterminput_unmarshaller *how, struct libterminput_mouseevent *what) +{ + what->type = LIBTERMINPUT_MOUSEEVENT; + if (how->load(how, &what->event, sizeof(what->event)) || + how->load(how, &what->x, sizeof(size_t) * 2U)) + return -1; + what->mods = 0; + what->button = LIBTERMINPUT_BUTTON1; + if (what->event == LIBTERMINPUT_HIGHLIGHT_OUTSIDE) { + if (how->load(how, &what->start_x, sizeof(size_t) * 4U)) + return -1; + } else if (what->event != LIBTERMINPUT_HIGHLIGHT_INSIDE) { + if (how->load(how, &what->mods, sizeof(what->mods)) || + how->load(how, &what->button, sizeof(what->button))) + return -1; + } + return 0; +} -- cgit v1.2.3-70-g09d2