1
0
Fork 0

backends/native: Send lores scroll in the middle of the detent

Some mice send a value slightly lower than 120 for some detents. The
current approach waits until a value of 120 is reached before sending a
low-resolution scroll event.

For example, the MX Master 3 sends a value of 112 in some detents:

              detent                   detent
    |                        |                       |
                        ^    ^                    ^
                        112  REL_WHEEL            224

As illustrated, only one event was sent but two were expected. However,
sending the low-resolution scroll event in the middle plus the existing
heuristics to reset the accumulator solve this issue:

              detent                   detent
    |                        |                       |
                ^          ^             ^          ^
                REL_WHEEL  112           REL_WHEEL  224

Send low-resolution scroll events in the middle of the detent to solve
this problem.

Fix https://gitlab.gnome.org/GNOME/mutter/-/issues/2469

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2668>
This commit is contained in:
José Expósito 2022-10-17 18:56:29 +02:00 committed by Marge Bot
parent 714f01048e
commit 5fa1a8cf42

View file

@ -916,7 +916,7 @@ meta_seat_impl_notify_discrete_scroll_in_impl (MetaSeatImpl *seat_impl,
{
MetaInputDeviceNative *evdev_device;
double dx = 0, dy = 0;
int discrete_dx = 0, discrete_dy = 0;
int low_res_value = 0;
/* Convert into DISCRETE_SCROLL_STEP range. 120/DISCRETE_SCROLL_STEP = 12.0 */
dx = dx_value120 / 12.0;
@ -949,23 +949,29 @@ meta_seat_impl_notify_discrete_scroll_in_impl (MetaSeatImpl *seat_impl,
evdev_device->value120.acc_dx += dx_value120;
evdev_device->value120.acc_dy += dy_value120;
discrete_dx = (evdev_device->value120.acc_dx / 120);
discrete_dy = (evdev_device->value120.acc_dy / 120);
if (discrete_dx != 0)
if (abs (evdev_device->value120.acc_dx) >= 60)
{
evdev_device->value120.acc_dx -= (discrete_dx * 120);
low_res_value = (evdev_device->value120.acc_dx / 120);
if (low_res_value == 0)
low_res_value = (dx_value120 > 0) ? 1 : -1;
notify_discrete_scroll (input_device, time_us,
discrete_to_direction (discrete_dx, 0),
discrete_to_direction (low_res_value, 0),
scroll_source, FALSE);
evdev_device->value120.acc_dx -= (low_res_value * 120);
}
if (discrete_dy != 0)
if (abs (evdev_device->value120.acc_dy) >= 60)
{
evdev_device->value120.acc_dy -= (discrete_dy * 120);
low_res_value = (evdev_device->value120.acc_dy / 120);
if (low_res_value == 0)
low_res_value = (dy_value120 > 0) ? 1 : -1;
notify_discrete_scroll (input_device, time_us,
discrete_to_direction (0, discrete_dy),
discrete_to_direction (0, low_res_value),
scroll_source, FALSE);
evdev_device->value120.acc_dy -= (low_res_value * 120);
}
}