summaryrefslogtreecommitdiffstats
path: root/video/out/wayland_common.c
diff options
context:
space:
mode:
authorJan Ekström <jeebjp@gmail.com>2020-03-18 20:14:50 +0200
committerDudemanguy <random342@airmail.cc>2020-03-19 20:27:55 +0000
commit33519d61aa67fca41cdae79935f6e2d2ab3c32be (patch)
tree9230c4760d4920d1a35feec3f839024e7d129120 /video/out/wayland_common.c
parent3aad89829f832091d483589fd578f6ab5b8ba685 (diff)
downloadmpv-33519d61aa67fca41cdae79935f6e2d2ab3c32be.tar.bz2
mpv-33519d61aa67fca41cdae79935f6e2d2ab3c32be.tar.xz
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.
Diffstat (limited to 'video/out/wayland_common.c')
-rw-r--r--video/out/wayland_common.c5
1 files changed, 2 insertions, 3 deletions
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)