From 70cc73b8d88387af36dbb7bd0e85d1ce27feb456 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Philipp=20Br=C3=BCschweiler?= Date: Tue, 14 Aug 2012 11:02:42 +0200 Subject: [PATCH] eventdemo: add axis logging https://bugs.freedesktop.org/show_bug.cgi?id=52453 --- clients/eventdemo.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/clients/eventdemo.c b/clients/eventdemo.c index 49e4399..569a8c1 100644 --- a/clients/eventdemo.c +++ b/clients/eventdemo.c @@ -70,6 +70,9 @@ static int log_key = 0; /** set to log button events */ static int log_button = 0; +/** set to log axis events */ +static int log_axis = 0; + /** set to log motion events */ static int log_motion = 0; @@ -230,6 +233,29 @@ button_handler(struct widget *widget, struct input *input, uint32_t time, } /** + * \brief CALLBACK function, Wayland informs about axis event + * \param widget widget + * \param input input device that caused the axis event + * \param time time the event happened + * \param axis vertical or horizontal + * \param value amount of scrolling + * \param data user data associated to the widget + */ +static void +axis_handler(struct widget *widget, struct input *input, uint32_t time, + uint32_t axis, wl_fixed_t value, void *data) +{ + if (!log_axis) + return; + + printf("axis time: %d, axis: %s, value: %f\n", + time, + axis == WL_POINTER_AXIS_VERTICAL_SCROLL ? "vertical" : + "horizontal", + wl_fixed_to_double(value)); +} + +/** * \brief CALLBACK function, Waylands informs about pointer motion * \param widget widget * \param input input device that caused the motion event @@ -317,6 +343,9 @@ eventdemo_create(struct display *d) /* Set the callback motion handler for the window */ widget_set_motion_handler(e->widget, motion_handler); + /* Set the callback axis handler for the window */ + widget_set_axis_handler(e->widget, axis_handler); + /* Initial drawing of the window */ window_schedule_resize(e->window, width, height); @@ -347,6 +376,7 @@ static const struct weston_option eventdemo_options[] = { { WESTON_OPTION_BOOLEAN, "log-focus", '0', &log_focus }, { WESTON_OPTION_BOOLEAN, "log-key", '0', &log_key }, { WESTON_OPTION_BOOLEAN, "log-button", '0', &log_button }, + { WESTON_OPTION_BOOLEAN, "log-axis", '0', &log_axis }, { WESTON_OPTION_BOOLEAN, "log-motion", '0', &log_motion }, }; -- 2.7.4