aboutsummaryrefslogtreecommitdiffstats
path: root/libterminput_marshal_mouseevent__.c
blob: 7da80fe4c1988bebfc395c512e0705aaab74d7c9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* See LICENSE file for copyright and license details. */
#include "common.h"


int
libterminput_marshal_mouseevent__(struct libterminput_marshaller *how, const struct libterminput_mouseevent *what) /* TODO test */
{
	if (how->store(how, &what->event, sizeof(what->event)) ||
	    how->store(how, &what->x, sizeof(size_t) * 2U))
		return -1;
	if (what->event == LIBTERMINPUT_HIGHLIGHT_OUTSIDE) {
		if (how->store(how, &what->start_x, sizeof(size_t) * 4U))
			return -1;
	} else if (what->event != LIBTERMINPUT_HIGHLIGHT_INSIDE) {
		if (how->store(how, &what->mods, sizeof(what->mods)) ||
		    how->store(how, &what->button, sizeof(what->button)))
			return -1;
	}
	return 0;
}