OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/android/scoped_java_ref.h" | 5 #include "base/android/scoped_java_ref.h" |
6 #include "base/task_runner_util.h" | 6 #include "base/task_runner_util.h" |
7 #include "chrome/browser/android/vr_shell/vr_input_manager.h" | 7 #include "chrome/browser/android/vr_shell/vr_input_manager.h" |
8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
9 | 9 |
10 using blink::WebGestureEvent; | 10 using blink::WebGestureEvent; |
(...skipping 25 matching lines...) Expand all Loading... | |
36 | 36 |
37 if (gesture.type == WebInputEvent::GestureScrollBegin || | 37 if (gesture.type == WebInputEvent::GestureScrollBegin || |
38 gesture.type == WebInputEvent::GestureScrollUpdate || | 38 gesture.type == WebInputEvent::GestureScrollUpdate || |
39 gesture.type == WebInputEvent::GestureScrollEnd) { | 39 gesture.type == WebInputEvent::GestureScrollEnd) { |
40 SendScrollEvent(event_time_milliseconds, 0.0f, 0.0f, | 40 SendScrollEvent(event_time_milliseconds, 0.0f, 0.0f, |
41 gesture.details.scroll.delta.x, | 41 gesture.details.scroll.delta.x, |
42 gesture.details.scroll.delta.y, gesture.type); | 42 gesture.details.scroll.delta.y, gesture.type); |
43 } else if (gesture.type == WebInputEvent::GestureTap) { | 43 } else if (gesture.type == WebInputEvent::GestureTap) { |
44 SendClickEvent(event_time_milliseconds, gesture.details.buttons.pos.x, | 44 SendClickEvent(event_time_milliseconds, gesture.details.buttons.pos.x, |
45 gesture.details.buttons.pos.y); | 45 gesture.details.buttons.pos.y); |
46 } else if (gesture.type == WebInputEvent::MouseMove) { | 46 } else if (gesture.type == WebInputEvent::MouseMove || |
47 gesture.type == WebInputEvent::MouseEnter || | |
48 gesture.type == WebInputEvent::MouseLeave) { | |
47 SendMouseMoveEvent(event_time_milliseconds, gesture.details.move.delta.x, | 49 SendMouseMoveEvent(event_time_milliseconds, gesture.details.move.delta.x, |
48 gesture.details.move.delta.y, gesture.details.move.type); | 50 gesture.details.move.delta.y, gesture.type); |
49 } | 51 } |
50 } | 52 } |
51 | 53 |
52 void VrInputManager::ScrollBegin(int64_t time_ms, | 54 void VrInputManager::ScrollBegin(int64_t time_ms, |
53 float x, | 55 float x, |
54 float y, | 56 float y, |
55 float hintx, | 57 float hintx, |
56 float hinty, | 58 float hinty, |
57 bool target_viewport) { | 59 bool target_viewport) { |
58 WebGestureEvent event = | 60 WebGestureEvent event = |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 } | 114 } |
113 case WebInputEvent::GestureScrollEnd: { | 115 case WebInputEvent::GestureScrollEnd: { |
114 WebGestureEvent event_end = | 116 WebGestureEvent event_end = |
115 MakeGestureEvent(WebInputEvent::GestureScrollEnd, time_ms, 0, 0); | 117 MakeGestureEvent(WebInputEvent::GestureScrollEnd, time_ms, 0, 0); |
116 ForwardGestureEvent(event_end); | 118 ForwardGestureEvent(event_end); |
117 break; | 119 break; |
118 } | 120 } |
119 } | 121 } |
120 } | 122 } |
121 | 123 |
122 void VrInputManager::SendMouseMoveEvent(int64_t time_ms, | 124 void VrInputManager::SendMouseMoveEvent(int64_t time_ms, |
bshe
2016/10/04 13:50:42
Nit: perhap rename to SendMouseEvent since this is
mthiesse
2016/10/04 14:05:26
Done.
| |
123 float x, | 125 float x, |
124 float y, | 126 float y, |
125 int type) { | 127 WebInputEvent::Type type) { |
126 WebMouseEvent result; | 128 WebMouseEvent result; |
127 | 129 |
128 result.type = WebInputEvent::MouseMove; | 130 result.type = type; |
129 result.pointerType = blink::WebPointerProperties::PointerType::Mouse; | 131 result.pointerType = blink::WebPointerProperties::PointerType::Mouse; |
130 result.x = x / dpi_scale_; | 132 result.x = x / dpi_scale_; |
131 result.y = y / dpi_scale_; | 133 result.y = y / dpi_scale_; |
132 result.windowX = x / dpi_scale_; | 134 result.windowX = x / dpi_scale_; |
133 result.windowY = y / dpi_scale_; | 135 result.windowY = y / dpi_scale_; |
134 result.timeStampSeconds = time_ms / 1000.0; | 136 result.timeStampSeconds = time_ms / 1000.0; |
135 result.clickCount = 1; | 137 result.clickCount = 1; |
136 result.modifiers = 0; | 138 result.modifiers = 0; |
137 | |
138 if (type == 1) { | |
139 result.type = WebInputEvent::MouseEnter; | |
140 } else if (type == 2) { | |
141 result.type = WebInputEvent::MouseLeave; | |
142 } | |
143 result.button = WebMouseEvent::Button::NoButton; | 139 result.button = WebMouseEvent::Button::NoButton; |
144 | 140 |
145 ForwardMouseEvent(result); | 141 ForwardMouseEvent(result); |
146 } | 142 } |
147 | 143 |
148 void VrInputManager::SendClickEvent(int64_t time_ms, float x, float y) { | 144 void VrInputManager::SendClickEvent(int64_t time_ms, float x, float y) { |
149 WebGestureEvent tap_down_event = | 145 WebGestureEvent tap_down_event = |
150 MakeGestureEvent(WebInputEvent::GestureTapDown, time_ms, x, y); | 146 MakeGestureEvent(WebInputEvent::GestureTapDown, time_ms, x, y); |
151 tap_down_event.data.tap.tapCount = 1; | 147 tap_down_event.data.tap.tapCount = 1; |
152 ForwardGestureEvent(tap_down_event); | 148 ForwardGestureEvent(tap_down_event); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
232 } | 228 } |
233 | 229 |
234 void VrInputManager::ForwardMouseEvent(const blink::WebMouseEvent& event) { | 230 void VrInputManager::ForwardMouseEvent(const blink::WebMouseEvent& event) { |
235 content::RenderWidgetHost* rwh = | 231 content::RenderWidgetHost* rwh = |
236 web_contents_->GetRenderWidgetHostView()->GetRenderWidgetHost(); | 232 web_contents_->GetRenderWidgetHostView()->GetRenderWidgetHost(); |
237 if (rwh) | 233 if (rwh) |
238 rwh->ForwardMouseEvent(event); | 234 rwh->ForwardMouseEvent(event); |
239 } | 235 } |
240 | 236 |
241 } // namespace vr_shell | 237 } // namespace vr_shell |
OLD | NEW |