Index: components/mus/display_manager.cc |
diff --git a/components/mus/display_manager.cc b/components/mus/display_manager.cc |
index 0bf73bff1e2eece67ae75c538c5d39ffa1d340bc..af29f1f6d4128ec12289b1f3ce1d724520a5c6fa 100644 |
--- a/components/mus/display_manager.cc |
+++ b/components/mus/display_manager.cc |
@@ -81,6 +81,15 @@ |
bounds_at_origin /* visible_rect */, view->surface_id()); |
} |
+float ConvertUIWheelValueToMojoValue(int offset) { |
+ // Mojo's event type takes a value between -1 and 1. Normalize by allowing |
+ // up to 20 of ui's offset. This is a bit arbitrary. |
+ return std::max( |
+ -1.0f, std::min(1.0f, static_cast<float>(offset) / |
+ (20 * static_cast<float>( |
+ ui::MouseWheelEvent::kWheelDelta)))); |
+} |
+ |
} // namespace |
// static |
@@ -257,6 +266,16 @@ |
void DefaultDisplayManager::DispatchEvent(ui::Event* event) { |
mojo::EventPtr mojo_event(mojo::Event::From(*event)); |
+ if (event->IsMouseWheelEvent()) { |
+ // Mojo's event type has a different meaning for wheel events. Convert |
+ // between the two. |
+ ui::MouseWheelEvent* wheel_event = static_cast<ui::MouseWheelEvent*>(event); |
+ DCHECK(mojo_event->pointer_data); |
+ mojo_event->pointer_data->horizontal_wheel = |
+ ConvertUIWheelValueToMojoValue(wheel_event->x_offset()); |
+ mojo_event->pointer_data->horizontal_wheel = |
+ ConvertUIWheelValueToMojoValue(wheel_event->y_offset()); |
+ } |
delegate_->OnEvent(mojo_event.Pass()); |
switch (event->type()) { |