From 529ce8e4ac74e3238768922f552d83e4de622721 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Friedrich=20Sch=C3=B6ller?= Date: Fri, 23 Jan 2015 22:31:05 +0100 Subject: [PATCH] tools: Check if axis value is available in debugging GUI MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit libinput complained with lots of "client bug" messages because the GUI tool did not check which axis values were available. Signed-off-by: Friedrich Schöller Signed-off-by: Peter Hutterer --- tools/event-gui.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tools/event-gui.c b/tools/event-gui.c index e574bf7..70dd854 100644 --- a/tools/event-gui.c +++ b/tools/event-gui.c @@ -358,19 +358,21 @@ static void handle_event_axis(struct libinput_event *ev, struct window *w) { struct libinput_event_pointer *p = libinput_event_get_pointer_event(ev); - double v, h; + double value; - v = libinput_event_pointer_get_axis_value(p, - LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL); - h = libinput_event_pointer_get_axis_value(p, - LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL); - - if (v != 0.0) { - w->vy += (int)v; + if (libinput_event_pointer_has_axis(p, + LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)) { + value = libinput_event_pointer_get_axis_value(p, + LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL); + w->vy += (int)value; w->vy = clip(w->vy, 0, w->height); } - if (h != 0.0) { - w->hx += (int)h; + + if (libinput_event_pointer_has_axis(p, + LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL)) { + value = libinput_event_pointer_get_axis_value(p, + LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL); + w->hx += (int)value; w->hx = clip(w->hx, 0, w->width); } } -- 2.7.4