summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornanahi <130121847+na-na-hi@users.noreply.github.com>2024-02-01 18:13:07 -0500
committerDudemanguy <random342@airmail.cc>2024-02-04 02:14:11 +0000
commitf95b7146d74287a00f10a8b0762634461a6aa215 (patch)
treee062e0da69001e73c9869261ff6a2b64e4edd6fc
parentfe0c181b1c3a73fb9d2a423d362a47d522e78c91 (diff)
downloadmpv-f95b7146d74287a00f10a8b0762634461a6aa215.tar.bz2
mpv-f95b7146d74287a00f10a8b0762634461a6aa215.tar.xz
wayland_common: properly handle high resolution scrolling
Commit f54ad8eb055771a080f079964504cb0f32fc4014 broke high resolution scrolling because one logical mouse click is generated for every scroll event, no matter the magnitude. This makes scrolling on trackpad way too fast. Revert the axis scaling change in that commit and clamp the resulting value between -1 and 1 to make sure mouse wheel scrolling works as intended on compositors which send a value larger than 10 for these events.
-rw-r--r--video/out/wayland_common.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 869e4e4b04..03e9e40ab1 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -295,7 +295,12 @@ static void pointer_handle_axis(void *data, struct wl_pointer *wl_pointer,
{
struct vo_wayland_state *wl = data;
- double val = wl_fixed_to_double(value) < 0 ? -1 : 1;
+ // The axis value is specified in logical coordinates, but the exact value emitted
+ // by one mouse wheel click is unspecified. In practice, most compositors use either
+ // 10 (GNOME, Weston) or 15 (wlroots, same as libinput) as the value.
+ // Divide the value by 10 and clamp it between -1 and 1 so that mouse wheel clicks
+ // work as intended on all compositors while still allowing high resolution trackpads.
+ double val = MPCLAMP(wl_fixed_to_double(value) / 10.0, -1, 1);
switch (axis) {
case WL_POINTER_AXIS_VERTICAL_SCROLL:
if (value > 0)