diff options
author | Pekka Paalanen <pekka.paalanen@collabora.co.uk> | 2016-04-12 13:33:09 +0300 |
---|---|---|
committer | Pekka Paalanen <pekka.paalanen@collabora.co.uk> | 2016-05-13 11:17:39 +0300 |
commit | 43864990a230f6acebe8f482151646619a333118 (patch) | |
tree | 102fdfa4e2d964d2028ad70682e8a5f7e2133a82 | |
parent | 6bc52540c0ac76338d5df0d6d6b78308154ef14f (diff) | |
download | weston-43864990a230f6acebe8f482151646619a333118.tar.gz |
eventdemo: do not print pointer frames alone
Print pointer frames only if any pointer related events are printed
first.
This avoids flooding the output with "pointer frame" just because of
motion. You can test this with e.g.
$ ./weston-eventdemo --log-button
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Tested-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Benoit Gschwind <gschwind@gnu-log.net>
Tested-by: Benoit Gschwind <gschwind@gnu-log.net>
-rw-r--r-- | clients/eventdemo.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/clients/eventdemo.c b/clients/eventdemo.c index e323aa50..f1558d23 100644 --- a/clients/eventdemo.c +++ b/clients/eventdemo.c @@ -35,6 +35,7 @@ #include <stdio.h> #include <stdlib.h> +#include <stdbool.h> #include <cairo.h> @@ -93,6 +94,8 @@ struct eventdemo { struct display *display; int x, y, w, h; + + bool print_pointer_frame; }; /** @@ -223,11 +226,14 @@ static void button_handler(struct widget *widget, struct input *input, uint32_t time, uint32_t button, enum wl_pointer_button_state state, void *data) { + struct eventdemo *e = data; int32_t x, y; if (!log_button) return; + e->print_pointer_frame = true; + input_get_position(input, &x, &y); printf("button time: %d, button: %d, state: %s, x: %d, y: %d\n", time, button, @@ -249,9 +255,13 @@ static void axis_handler(struct widget *widget, struct input *input, uint32_t time, uint32_t axis, wl_fixed_t value, void *data) { + struct eventdemo *e = data; + if (!log_axis) return; + e->print_pointer_frame = true; + printf("axis time: %d, axis: %s, value: %f\n", time, axis == WL_POINTER_AXIS_VERTICAL_SCROLL ? "vertical" : @@ -262,7 +272,13 @@ axis_handler(struct widget *widget, struct input *input, uint32_t time, static void pointer_frame_handler(struct widget *widget, struct input *input, void *data) { + struct eventdemo *e = data; + + if (!e->print_pointer_frame) + return; + printf("pointer frame\n"); + e->print_pointer_frame = false; } static void @@ -270,6 +286,9 @@ axis_source_handler(struct widget *widget, struct input *input, uint32_t source, void *data) { const char *axis_source; + struct eventdemo *e = data; + + e->print_pointer_frame = true; switch (source) { case WL_POINTER_AXIS_SOURCE_WHEEL: @@ -294,6 +313,9 @@ axis_stop_handler(struct widget *widget, struct input *input, uint32_t time, uint32_t axis, void *data) { + struct eventdemo *e = data; + + e->print_pointer_frame = true; printf("axis stop time: %d, axis: %s\n", time, axis == WL_POINTER_AXIS_VERTICAL_SCROLL ? "vertical" : @@ -304,6 +326,9 @@ static void axis_discrete_handler(struct widget *widget, struct input *input, uint32_t axis, int32_t discrete, void *data) { + struct eventdemo *e = data; + + e->print_pointer_frame = true; printf("axis discrete axis: %d value: %d\n", axis, discrete); } @@ -328,6 +353,7 @@ motion_handler(struct widget *widget, struct input *input, uint32_t time, if (log_motion) { printf("motion time: %d, x: %f, y: %f\n", time, x, y); + e->print_pointer_frame = true; } if (x > e->x && x < e->x + e->w) |