]>
Commit | Line | Data |
---|---|---|
cf6304f1 JB |
1 | From 358039182478140c8dcb7bcd077fff855d836bac Mon Sep 17 00:00:00 2001 |
2 | From: Peter Hutterer <peter.hutterer@who-t.net> | |
3 | Date: Fri, 16 Jan 2015 01:03:52 +0100 | |
4 | Subject: [PATCH] evdev: use libinput's new merged scroll events | |
5 | ||
6 | libinput's API changed from separate scroll events for vert/horiz scrolling to | |
7 | a single event that contains both axes if they changed. | |
8 | ||
9 | Updated by Armin K. to use the discrete axis value for wheel events as done | |
10 | in Weston. | |
11 | --- | |
12 | clutter/evdev/clutter-device-manager-evdev.c | 40 +++++++++++++++++++--------- | |
13 | configure.ac | 2 +- | |
14 | 2 files changed, 28 insertions(+), 14 deletions(-) | |
15 | ||
16 | diff --git a/clutter/evdev/clutter-device-manager-evdev.c b/clutter/evdev/clutter-device-manager-evdev.c | |
17 | index 7b48481..2b3828a 100644 | |
18 | --- a/clutter/evdev/clutter-device-manager-evdev.c | |
19 | +++ b/clutter/evdev/clutter-device-manager-evdev.c | |
20 | @@ -1191,29 +1191,43 @@ process_device_event (ClutterDeviceManagerEvdev *manager_evdev, | |
21 | ||
22 | case LIBINPUT_EVENT_POINTER_AXIS: | |
23 | { | |
24 | - gdouble value, dx = 0.0, dy = 0.0; | |
25 | + gdouble dx = 0.0, dy = 0.0; | |
26 | guint32 time; | |
27 | + gboolean wheel = FALSE; | |
28 | enum libinput_pointer_axis axis; | |
29 | + enum libinput_pointer_axis_source source; | |
30 | struct libinput_event_pointer *axis_event = | |
31 | libinput_event_get_pointer_event (event); | |
32 | + | |
33 | device = libinput_device_get_user_data (libinput_device); | |
34 | ||
35 | time = libinput_event_pointer_get_time (axis_event); | |
36 | - value = libinput_event_pointer_get_axis_value (axis_event); | |
37 | - axis = libinput_event_pointer_get_axis (axis_event); | |
38 | + source = libinput_event_pointer_get_axis_source (axis_event); | |
39 | ||
40 | - switch (axis) | |
41 | - { | |
42 | - case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL: | |
43 | - dx = 0; | |
44 | - dy = value; | |
45 | - break; | |
46 | + /* libinput < 0.8 sent wheel click events with value 10. Since 0.8 | |
47 | + the value is the angle of the click in degrees. To keep | |
48 | + backwards-compat with existing clients, we just send multiples of | |
49 | + the click count. */ | |
50 | + | |
51 | + if (source == LIBINPUT_POINTER_AXIS_SOURCE_WHEEL) | |
52 | + wheel = TRUE; | |
53 | ||
54 | - case LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL: | |
55 | - dx = value; | |
56 | - dy = 0; | |
57 | - break; | |
58 | + axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL; | |
59 | + if (libinput_event_pointer_has_axis (axis_event, axis)) | |
60 | + { | |
61 | + if (wheel) | |
62 | + dy = 10 * libinput_event_pointer_get_axis_value_discrete (axis_event, axis); | |
63 | + else | |
64 | + dy = libinput_event_pointer_get_axis_value (axis_event, axis); | |
65 | + } | |
66 | ||
67 | + axis = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL; | |
68 | + if (libinput_event_pointer_has_axis (axis_event, axis)) | |
69 | + { | |
70 | + if (wheel) | |
71 | + dx = 10 * libinput_event_pointer_get_axis_value_discrete (axis_event, axis); | |
72 | + else | |
73 | + dx = libinput_event_pointer_get_axis_value (axis_event, axis); | |
74 | } | |
75 | ||
76 | notify_scroll (device, time, dx, dy); | |
77 | diff --git a/configure.ac b/configure.ac | |
78 | index 0a9a580..2a47744 100644 | |
79 | --- a/configure.ac | |
80 | +++ b/configure.ac | |
81 | @@ -146,7 +146,7 @@ m4_define([uprof_req_version], [0.3]) | |
82 | m4_define([gtk_doc_req_version], [1.20]) | |
83 | m4_define([xcomposite_req_version], [0.4]) | |
84 | m4_define([gdk_req_version], [3.3.18]) | |
85 | -m4_define([libinput_req_version], [0.4.0]) | |
86 | +m4_define([libinput_req_version], [0.8.0]) | |
87 | m4_define([libudev_req_version], [136]) | |
88 | ||
89 | AC_SUBST([GLIB_REQ_VERSION], [glib_req_version]) | |
90 | -- | |
91 | 2.2.2 | |
92 |