From 7ed92c845fbaf145e0afe9182ba564898fd734e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Sun, 5 Jan 2014 16:03:59 +0100 Subject: [PATCH] Fix scaling of pointer axis vectors The vector of libinput and Wayland pointer axis events are in pointer motion coordinate space. To convert to clutter's internal representation the vectors need to be scaled to Xi2 scroll steps. https://bugzilla.gnome.org/show_bug.cgi?id=723560 --- clutter/evdev/clutter-device-manager-evdev.c | 6 +++++- clutter/wayland/clutter-input-device-wayland.c | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/clutter/evdev/clutter-device-manager-evdev.c b/clutter/evdev/clutter-device-manager-evdev.c index 17d2ac81a..9065fdc84 100644 --- a/clutter/evdev/clutter-device-manager-evdev.c +++ b/clutter/evdev/clutter-device-manager-evdev.c @@ -442,7 +442,7 @@ notify_scroll (ClutterInputDevice *input_device, ClutterStage *stage; ClutterEvent *event = NULL; ClutterPoint point; - const gdouble scroll_factor = 10.0f; + gdouble scroll_factor; /* We can drop the event on the floor if no stage has been * associated with the device yet. */ @@ -460,7 +460,11 @@ notify_scroll (ClutterInputDevice *input_device, event->scroll.device = seat->core_pointer; _clutter_xkb_translate_state (event, seat->xkb, seat->button_state); + /* libinput pointer axis events are in pointer motion coordinate space. + * To convert to Xi2 discrete step coordinate space, multiply the factor + * 1/10. */ event->scroll.direction = CLUTTER_SCROLL_SMOOTH; + scroll_factor = 1.0 / 10.0; clutter_event_set_scroll_delta (event, scroll_factor * dx, scroll_factor * dy); diff --git a/clutter/wayland/clutter-input-device-wayland.c b/clutter/wayland/clutter-input-device-wayland.c index a3c9c1958..7bfb615b7 100644 --- a/clutter/wayland/clutter-input-device-wayland.c +++ b/clutter/wayland/clutter-input-device-wayland.c @@ -167,6 +167,7 @@ clutter_wayland_handle_axis (void *data, ClutterStageCogl *stage_cogl; ClutterEvent *event; gdouble delta_x, delta_y; + gdouble delta_factor; if (!device->pointer_focus) return; @@ -179,15 +180,19 @@ clutter_wayland_handle_axis (void *data, event->scroll.x = device->x; event->scroll.y = device->y; + /* Wayland pointer axis events are in pointer motion coordinate space. + * To convert to Xi2 discrete step coordinate space, multiply the factor + * 1/10. */ + delta_factor = 1.0 / 10.0; if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) { - delta_x = -wl_fixed_to_double(value) * 23; + delta_x = wl_fixed_to_double (value) * delta_factor; delta_y = 0; } else { delta_x = 0; - delta_y = -wl_fixed_to_double(value) * 23; /* XXX: based on my bcm5794 */ + delta_y = wl_fixed_to_double (value) * delta_factor; } clutter_event_set_scroll_delta (event, delta_x, delta_y);