From 11e0558f917984f1b5e36722851d2f29ef1968f0 Mon Sep 17 00:00:00 2001 From: Stephen Chandler Paul Date: Tue, 5 Aug 2014 17:49:39 -0400 Subject: [PATCH] tablet: Add libinput_tool_get/set_user_data() Signed-off-by: Stephen Chandler Paul Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer --- src/libinput-private.h | 1 + src/libinput.c | 13 +++++++++++++ src/libinput.h | 23 +++++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/src/libinput-private.h b/src/libinput-private.h index 6ec36376..81875644 100644 --- a/src/libinput-private.h +++ b/src/libinput-private.h @@ -109,6 +109,7 @@ struct libinput_tool { uint32_t serial; enum libinput_tool_type type; int refcount; + void *user_data; }; typedef void (*libinput_source_dispatch_t)(void *data); diff --git a/src/libinput.c b/src/libinput.c index 9aa7cbcf..68187d8c 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -599,6 +599,19 @@ libinput_tool_get_serial(struct libinput_tool *tool) return tool->serial; } +LIBINPUT_EXPORT void +libinput_tool_set_user_data(struct libinput_tool *tool, + void *user_data) +{ + tool->user_data = user_data; +} + +LIBINPUT_EXPORT void * +libinput_tool_get_user_data(struct libinput_tool *tool) +{ + return tool->user_data; +} + LIBINPUT_EXPORT struct libinput_tool * libinput_tool_ref(struct libinput_tool *tool) { diff --git a/src/libinput.h b/src/libinput.h index a9ad379a..1d4952b0 100644 --- a/src/libinput.h +++ b/src/libinput.h @@ -1034,6 +1034,29 @@ libinput_tool_unref(struct libinput_tool *tool); uint32_t libinput_tool_get_serial(struct libinput_tool *tool); +/** + * @ingroup event_tablet + * + * Return the user data associated with a tool object. + * + * @param tool The libinput tool + * @return The user data associated with the tool object + */ +void * +libinput_tool_get_user_data(struct libinput_tool *tool); + +/** + * @ingroup event_tablet + * + * Set the user data associated with a tool object. + * + * @param tool The libinput tool + * @param user_data The user data to associate with the tool object + */ +void +libinput_tool_set_user_data(struct libinput_tool *tool, + void *user_data); + /** * @defgroup base Initialization and manipulation of libinput contexts */