From 0a95e4aa78189997d566f6a709f79ae981cd4eef Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Wed, 20 Feb 2019 08:56:36 +0100 Subject: [PATCH] Fixed #5262: Vertical mouse wheel direction and whell step * Vertical wheel uses the inverted direction of horizontal wheel. * The wheel step is now calculated from the value provided by wayland. --- client/Wayland/wlf_input.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/client/Wayland/wlf_input.c b/client/Wayland/wlf_input.c index cefd52d..e219496 100644 --- a/client/Wayland/wlf_input.c +++ b/client/Wayland/wlf_input.c @@ -123,6 +123,7 @@ BOOL wlf_handle_pointer_axis(freerdp* instance, const UwacPointerAxisEvent* ev) rdpInput* input; UINT16 flags = 0; int direction; + uint32_t step; uint32_t x, y; if (!instance || !ev || !instance->input) @@ -136,27 +137,31 @@ BOOL wlf_handle_pointer_axis(freerdp* instance, const UwacPointerAxisEvent* ev) input = instance->input; + direction = wl_fixed_to_int(ev->value); switch (ev->axis) { case WL_POINTER_AXIS_VERTICAL_SCROLL: flags |= PTR_FLAGS_WHEEL; + if (direction > 0) + flags |= PTR_FLAGS_WHEEL_NEGATIVE; break; case WL_POINTER_AXIS_HORIZONTAL_SCROLL: flags |= PTR_FLAGS_HWHEEL; + if (direction < 0) + flags |= PTR_FLAGS_WHEEL_NEGATIVE; break; default: return FALSE; } - direction = wl_fixed_to_int(ev->value); - flags |= 0x0078; /* TODO: Calculate the distance with the provided value size */ - - if (direction < 0) - flags |= PTR_FLAGS_WHEEL_NEGATIVE; + step = (uint32_t)abs(direction); + if (step > WheelRotationMask) + step = WheelRotationMask; + flags |= step; - return freerdp_input_send_mouse_event(input, flags, x, y); + return freerdp_input_send_mouse_event(input, flags, (UINT16)x, (UINT16)y); } BOOL wlf_handle_key(freerdp* instance, const UwacKeyEvent* ev) -- 2.7.4