1
0
Fork 0

evdev: use libinput's new merged scroll events

libinput's API changed from separate scroll events for vert/horiz scrolling to
a single event that contains both axes if they changed.

Updated by Armin K. to use the discrete axis value for wheel events as done
in Weston.

https://bugzilla.gnome.org/show_bug.cgi?id=742829
This commit is contained in:
Peter Hutterer 2015-01-16 01:03:52 +01:00 committed by Emmanuele Bassi
parent 7eb1a3d35f
commit ede13b11d7
2 changed files with 28 additions and 14 deletions

View file

@ -1191,29 +1191,43 @@ process_device_event (ClutterDeviceManagerEvdev *manager_evdev,
case LIBINPUT_EVENT_POINTER_AXIS: case LIBINPUT_EVENT_POINTER_AXIS:
{ {
gdouble value, dx = 0.0, dy = 0.0; gdouble dx = 0.0, dy = 0.0;
guint32 time; guint32 time;
gboolean wheel = FALSE;
enum libinput_pointer_axis axis; enum libinput_pointer_axis axis;
enum libinput_pointer_axis_source source;
struct libinput_event_pointer *axis_event = struct libinput_event_pointer *axis_event =
libinput_event_get_pointer_event (event); libinput_event_get_pointer_event (event);
device = libinput_device_get_user_data (libinput_device); device = libinput_device_get_user_data (libinput_device);
time = libinput_event_pointer_get_time (axis_event); time = libinput_event_pointer_get_time (axis_event);
value = libinput_event_pointer_get_axis_value (axis_event); source = libinput_event_pointer_get_axis_source (axis_event);
axis = libinput_event_pointer_get_axis (axis_event);
switch (axis) /* libinput < 0.8 sent wheel click events with value 10. Since 0.8
the value is the angle of the click in degrees. To keep
backwards-compat with existing clients, we just send multiples of
the click count. */
if (source == LIBINPUT_POINTER_AXIS_SOURCE_WHEEL)
wheel = TRUE;
axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL;
if (libinput_event_pointer_has_axis (axis_event, axis))
{ {
case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL: if (wheel)
dx = 0; dy = 10 * libinput_event_pointer_get_axis_value_discrete (axis_event, axis);
dy = value; else
break; dy = libinput_event_pointer_get_axis_value (axis_event, axis);
}
case LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL:
dx = value;
dy = 0;
break;
axis = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL;
if (libinput_event_pointer_has_axis (axis_event, axis))
{
if (wheel)
dx = 10 * libinput_event_pointer_get_axis_value_discrete (axis_event, axis);
else
dx = libinput_event_pointer_get_axis_value (axis_event, axis);
} }
notify_scroll (device, time, dx, dy); notify_scroll (device, time, dx, dy);

View file

@ -146,7 +146,7 @@ m4_define([uprof_req_version], [0.3])
m4_define([gtk_doc_req_version], [1.20]) m4_define([gtk_doc_req_version], [1.20])
m4_define([xcomposite_req_version], [0.4]) m4_define([xcomposite_req_version], [0.4])
m4_define([gdk_req_version], [3.3.18]) m4_define([gdk_req_version], [3.3.18])
m4_define([libinput_req_version], [0.4.0]) m4_define([libinput_req_version], [0.8.0])
m4_define([libudev_req_version], [136]) m4_define([libudev_req_version], [136])
AC_SUBST([GLIB_REQ_VERSION], [glib_req_version]) AC_SUBST([GLIB_REQ_VERSION], [glib_req_version])