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.
This commit is contained in:
Jan Ekström 2020-03-18 20:14:50 +02:00 committed by Dudemanguy
parent 3aad89829f
commit 33519d61aa
1 changed files with 2 additions and 3 deletions

View File

@ -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)