From 33519d61aa67fca41cdae79935f6e2d2ab3c32be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= Date: Wed, 18 Mar 2020 20:14:50 +0200 Subject: wayland: simplify mouse wheel direction calculation Based on an idea by sfan5. Remove abs usage, and instead just check for negative value, and set variable to either +/-1. --- video/out/wayland_common.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'video/out') diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index ebb22e23c0..55a4c36f1e 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -251,9 +251,8 @@ static void pointer_handle_axis(void *data, struct wl_pointer *wl_pointer, uint32_t time, uint32_t axis, wl_fixed_t value) { struct vo_wayland_state *wl = data; - if (wl_fixed_to_double(value) == 0) - return; - double val = wl_fixed_to_double(value)/abs(wl_fixed_to_double(value)); + + double val = wl_fixed_to_double(value) < 0 ? -1 : 1; switch (axis) { case WL_POINTER_AXIS_VERTICAL_SCROLL: if (value > 0) -- cgit v1.2.3