Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(353)

Unified Diff: components/mus/display_manager.cc

Issue 1344223002: Revert of Overhaul Mandoline event transport code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/html_viewer/touch_handler.cc ('k') | components/mus/event_dispatcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()) {
« no previous file with comments | « components/html_viewer/touch_handler.cc ('k') | components/mus/event_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698