The new API returns scroll wheels as fractions of 120.

Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
---
Turns out it's not the most complicated patch...

This is an RFC only because libinput hasn't been released yet, and it's
waiting on the kernel release anyway. Given the expected delay, I hope
autotools is removed by the time this becomes a mergeable.

 libweston/libinput-device.c | 6 ++++++
 meson.build                 | 9 +++++++++
 2 files changed, 15 insertions(+)

diff --git a/libweston/libinput-device.c b/libweston/libinput-device.c
index e25df144..e028d246 100644
--- a/libweston/libinput-device.c
+++ b/libweston/libinput-device.c
@@ -190,9 +190,15 @@ normalize_scroll(struct libinput_event_pointer 
*pointer_event,
         */
        switch (source) {
        case LIBINPUT_POINTER_AXIS_SOURCE_WHEEL:
+#if HAVE_LIBINPUT_AXIS_V120
+               value = 10 * libinput_event_pointer_get_axis_value_v120(
+                                                                  
pointer_event,
+                                                                  axis)/120.0;
+#else
                value = 10 * libinput_event_pointer_get_axis_value_discrete(
                                                                   
pointer_event,
                                                                   axis);
+#endif
                break;
        case LIBINPUT_POINTER_AXIS_SOURCE_FINGER:
        case LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS:
diff --git a/meson.build b/meson.build
index 7826dbb0..dfb10ce5 100644
--- a/meson.build
+++ b/meson.build
@@ -143,6 +143,15 @@ dep_wayland_server = dependency('wayland-server', version: 
'>= 1.12.0')
 dep_wayland_client = dependency('wayland-client', version: '>= 1.12.0')
 dep_pixman = dependency('pixman-1', version: '>= 0.25.2')
 dep_libinput = dependency('libinput', version: '>= 0.8.0')
+have_libinput_axis_v120_code = '''
+#include <libinput.h>
+int main(void) { libinput_event_pointer_get_axis_value_v120(NULL, 0); }
+'''
+have_libinput_axis_v120 = cc.links(have_libinput_axis_v120_code,
+                                  name: 
'libinput_event_pointer_get_axis_value_v120',
+                                  dependencies: dep_libinput)
+config_h.set10('HAVE_LIBINPUT_AXIS_V120', have_libinput_axis_v120)
+
 dep_libm = cc.find_library('m')
 dep_libdl = cc.find_library('dl')
 dep_libdrm = dependency('libdrm', version: '>= 2.4.68')
-- 
2.20.1

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to