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
This commit is contained in:
Jonas Ådahl 2014-01-05 16:03:59 +01:00 committed by Emmanuele Bassi
parent 3da27a4f08
commit 7ed92c845f
2 changed files with 12 additions and 3 deletions

View File

@ -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);

View File

@ -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);