Commit 7bccf17a authored by Nick Diego Yamane's avatar Nick Diego Yamane Committed by Chromium LUCI CQ

ozone/wayland: Fix horizontal scroll direction

wl_pointer's horizontal offsets were being handled differently from
vertical ones. This causes the effect observed in crbug.com/986258.
This CL fixes it as well as updates the associated test expectations.

Test: Covered by ozone_unitests. Also, testable manually as follows:
  - Open any webpage with horizontal scroll bar;
  - Scroll it, using either a touchpad or mouse;
  - In Sway compositor, the following command can be used to enable
    "natural scroll", as mentioned in the bug report:
    $ swaymsg input "<touchpad id here>" natural_scroll enabled
  - whereas touchpad id is retrieved through 'swaymsg -t get_inputs'
  command.

R=msisov@igalia.com

Bug: 986258
Change-Id: I0bb835aae47ff0bcb99b67b39d32738b0088a80e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2579652Reviewed-by: default avatarAntonio Gomes <tonikitoo@igalia.com>
Commit-Queue: Nick Yamane <nickdiego@igalia.com>
Cr-Commit-Position: refs/heads/master@{#835392}
parent 0ccb0d8e
......@@ -130,7 +130,7 @@ void WaylandPointer::Axis(void* data,
offset.set_y(-wl_fixed_to_double(value) / kAxisValueScale *
MouseWheelEvent::kWheelDelta);
} else if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) {
offset.set_x(wl_fixed_to_double(value) / kAxisValueScale *
offset.set_x(-wl_fixed_to_double(value) / kAxisValueScale *
MouseWheelEvent::kWheelDelta);
} else {
return;
......
......@@ -234,7 +234,7 @@ TEST_P(WaylandPointerTest, AxisHorizontal) {
ASSERT_TRUE(event);
ASSERT_TRUE(event->IsMouseWheelEvent());
auto* mouse_wheel_event = event->AsMouseWheelEvent();
EXPECT_EQ(gfx::Vector2d(MouseWheelEvent::kWheelDelta, 0),
EXPECT_EQ(gfx::Vector2d(-MouseWheelEvent::kWheelDelta, 0),
mouse_wheel_event->offset());
EXPECT_EQ(EF_LEFT_MOUSE_BUTTON, mouse_wheel_event->button_flags());
EXPECT_EQ(0, mouse_wheel_event->changed_button_flags());
......@@ -340,11 +340,11 @@ TEST_P(WaylandPointerTest, FlingVertical) {
EXPECT_EQ(ET_SCROLL_FLING_START, scroll_event->type());
EXPECT_EQ(gfx::PointF(50, 75), scroll_event->location_f());
EXPECT_EQ(0.0f, scroll_event->x_offset());
EXPECT_EQ(0.0f, scroll_event->x_offset_ordinal());
// Initial vertical velocity depends on the implementation outside of
// WaylandPointer, but it should be negative value based on the direction of
// recent two axis events.
EXPECT_GT(0.0f, scroll_event->y_offset());
EXPECT_EQ(0.0f, scroll_event->x_offset_ordinal());
EXPECT_GT(0.0f, scroll_event->y_offset_ordinal());
}
......@@ -393,13 +393,13 @@ TEST_P(WaylandPointerTest, FlingHorizontal) {
auto* scroll_event = event3->AsScrollEvent();
EXPECT_EQ(ET_SCROLL_FLING_START, scroll_event->type());
EXPECT_EQ(gfx::PointF(50, 75), scroll_event->location_f());
// Initial horizontal velocity depends on the implementation outside of
// WaylandPointer, but it should be positive value based on the direction of
// recent two axis events.
EXPECT_LT(0.0f, scroll_event->x_offset());
EXPECT_EQ(0.0f, scroll_event->y_offset());
EXPECT_LT(0.0f, scroll_event->x_offset_ordinal());
EXPECT_EQ(0.0f, scroll_event->y_offset_ordinal());
// Initial horizontal velocity depends on the implementation outside of
// WaylandPointer, but it should be negative value based on the direction of
// recent two axis events.
EXPECT_GT(0.0f, scroll_event->x_offset());
EXPECT_GT(0.0f, scroll_event->x_offset_ordinal());
}
TEST_P(WaylandPointerTest, FlingCancel) {
......@@ -518,10 +518,10 @@ TEST_P(WaylandPointerTest, FlingDiagonal) {
auto* scroll_event = event5->AsScrollEvent();
EXPECT_EQ(ET_SCROLL_FLING_START, scroll_event->type());
EXPECT_EQ(gfx::PointF(50, 75), scroll_event->location_f());
// Check the offset direction. It should non-zero in both directions.
EXPECT_LT(0.0f, scroll_event->x_offset());
// Check the offset direction. It should non-zero in both axes.
EXPECT_GT(0.0f, scroll_event->x_offset());
EXPECT_GT(0.0f, scroll_event->y_offset());
EXPECT_LT(0.0f, scroll_event->x_offset_ordinal());
EXPECT_GT(0.0f, scroll_event->x_offset_ordinal());
EXPECT_GT(0.0f, scroll_event->y_offset_ordinal());
// Horizontal offset should be larger than vertical one, given the scroll
// offset in each direction.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment