From c77e943ce21b3bca4f1284a576537ada8e6a2375 Mon Sep 17 00:00:00 2001 From: Pascal Nowack Date: Thu, 11 Feb 2021 12:33:26 +0100 Subject: [PATCH] backends/native: Handle triple resolution mouse wheels better When a remote desktop user emits a virtual smooth scrolling event, a smooth scroll event, that is not emulated, is emitted and on occasion a discrete scroll event, that is emulated, is emitted. As base for the discrete scrolling event, the smooth scrolling steps are accumulated. When the accumulated smooth scrolling steps surpass the DISCRETE_SCROLL_STEP, the discrete scrolling event is emitted. Currently, mutter uses for DISCRETE_SCROLL_STEP the value 10, which is a terrible value to work with, especially for high resolution mouse wheels. When a triple resolution mouse wheel is used, each scrolling step will have the value 3 1/3. Three of such events won't however surpass the DISCRETE_SCROLL_STEP. To fix this situation, add DBL_EPSILON to the calculation step, when checking for the discrete scroll event to ensure that 3 smooth scroll events, with each having the value 3 1/3, emit a discrete scrolling event. Part-of: --- src/backends/native/meta-seat-impl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/backends/native/meta-seat-impl.c b/src/backends/native/meta-seat-impl.c index 25608e436..b2c5e63e5 100644 --- a/src/backends/native/meta-seat-impl.c +++ b/src/backends/native/meta-seat-impl.c @@ -818,8 +818,10 @@ check_notify_discrete_scroll (MetaSeatImpl *seat_impl, { int i, n_xscrolls, n_yscrolls; - n_xscrolls = floor (fabs (seat_impl->accum_scroll_dx) / DISCRETE_SCROLL_STEP); - n_yscrolls = floor (fabs (seat_impl->accum_scroll_dy) / DISCRETE_SCROLL_STEP); + n_xscrolls = floor ((fabs (seat_impl->accum_scroll_dx) + DBL_EPSILON) / + DISCRETE_SCROLL_STEP); + n_yscrolls = floor ((fabs (seat_impl->accum_scroll_dy) + DBL_EPSILON) / + DISCRETE_SCROLL_STEP); for (i = 0; i < n_xscrolls; i++) {