From 538749de7b7a3229d798a99bc4a78d1d8bc17bdf Mon Sep 17 00:00:00 2001 From: Alexandros Frantzis Date: Fri, 16 Feb 2018 18:44:16 +0200 Subject: [PATCH] libweston: Introduce input-timestamps support Introduce code to support the implementation of the input_timestamps_unstable_v1 protocol in libweston. This commit does not implement the actual timestamp subscriptions, but sets up the zwp_input_timestamps_manager_v1 object and introduces dummy request handling functions for it, laying the foundation for timestamp subscriptions for keyboard/pointer/touch to be added cleanly in upcoming commits. Signed-off-by: Alexandros Frantzis Reviewed-by: Pekka Paalanen --- Makefile.am | 4 ++- libweston/input.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 679e6b78..e028a2a1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -166,7 +166,9 @@ nodist_libweston_@LIBWESTON_MAJOR@_la_SOURCES = \ protocol/relative-pointer-unstable-v1-protocol.c \ protocol/relative-pointer-unstable-v1-server-protocol.h \ protocol/pointer-constraints-unstable-v1-protocol.c \ - protocol/pointer-constraints-unstable-v1-server-protocol.h + protocol/pointer-constraints-unstable-v1-server-protocol.h \ + protocol/input-timestamps-unstable-v1-protocol.c \ + protocol/input-timestamps-unstable-v1-server-protocol.h BUILT_SOURCES += $(nodist_libweston_@LIBWESTON_MAJOR@_la_SOURCES) diff --git a/libweston/input.c b/libweston/input.c index da002548..2e8bd088 100644 --- a/libweston/input.c +++ b/libweston/input.c @@ -42,6 +42,7 @@ #include "compositor.h" #include "relative-pointer-unstable-v1-server-protocol.h" #include "pointer-constraints-unstable-v1-server-protocol.h" +#include "input-timestamps-unstable-v1-server-protocol.h" enum pointer_constraint_type { POINTER_CONSTRAINT_TYPE_LOCK, @@ -4569,6 +4570,67 @@ bind_pointer_constraints(struct wl_client *client, void *data, NULL, NULL); } +static void +input_timestamps_manager_destroy(struct wl_client *client, + struct wl_resource *resource) +{ + wl_resource_destroy(resource); +} + +static void +input_timestamps_manager_get_keyboard_timestamps(struct wl_client *client, + struct wl_resource *resource, + uint32_t id, + struct wl_resource *keyboard_resource) +{ + wl_client_post_no_memory(client); +} + +static void +input_timestamps_manager_get_pointer_timestamps(struct wl_client *client, + struct wl_resource *resource, + uint32_t id, + struct wl_resource *pointer_resource) +{ + wl_client_post_no_memory(client); +} + +static void +input_timestamps_manager_get_touch_timestamps(struct wl_client *client, + struct wl_resource *resource, + uint32_t id, + struct wl_resource *touch_resource) +{ + wl_client_post_no_memory(client); +} + +static const struct zwp_input_timestamps_manager_v1_interface + input_timestamps_manager_interface = { + input_timestamps_manager_destroy, + input_timestamps_manager_get_keyboard_timestamps, + input_timestamps_manager_get_pointer_timestamps, + input_timestamps_manager_get_touch_timestamps, +}; + +static void +bind_input_timestamps_manager(struct wl_client *client, void *data, + uint32_t version, uint32_t id) +{ + struct wl_resource *resource = + wl_resource_create(client, + &zwp_input_timestamps_manager_v1_interface, + 1, id); + + if (resource == NULL) { + wl_client_post_no_memory(client); + return; + } + + wl_resource_set_implementation(resource, + &input_timestamps_manager_interface, + NULL, NULL); +} + int weston_input_init(struct weston_compositor *compositor) { @@ -4582,5 +4644,10 @@ weston_input_init(struct weston_compositor *compositor) NULL, bind_pointer_constraints)) return -1; + if (!wl_global_create(compositor->wl_display, + &zwp_input_timestamps_manager_v1_interface, 1, + NULL, bind_input_timestamps_manager)) + return -1; + return 0; }