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 */