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

Side by Side Diff: chrome/browser/android/vr_shell/android_ui_gesture_target.cc

Issue 2942623002: VR: Add support for mouse down/up events for Android NativePages. (Closed)
Patch Set: Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "chrome/browser/android/vr_shell/android_ui_gesture_target.h" 5 #include "chrome/browser/android/vr_shell/android_ui_gesture_target.h"
6 6
7 #include "jni/MotionEventSynthesizer_jni.h" 7 #include "jni/MotionEventSynthesizer_jni.h"
8 8
9 namespace vr_shell { 9 namespace vr_shell {
10 10
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 Inject(env, Action::HoverEnter, gesture->TimeStampSeconds()); 64 Inject(env, Action::HoverEnter, gesture->TimeStampSeconds());
65 break; 65 break;
66 case blink::WebMouseEvent::kMouseMove: 66 case blink::WebMouseEvent::kMouseMove:
67 SetPointer(env, mouse->PositionInWidget().x, mouse->PositionInWidget().y); 67 SetPointer(env, mouse->PositionInWidget().x, mouse->PositionInWidget().y);
68 Inject(env, Action::HoverMove, gesture->TimeStampSeconds()); 68 Inject(env, Action::HoverMove, gesture->TimeStampSeconds());
69 break; 69 break;
70 case blink::WebMouseEvent::kMouseLeave: 70 case blink::WebMouseEvent::kMouseLeave:
71 SetPointer(env, mouse->PositionInWidget().x, mouse->PositionInWidget().y); 71 SetPointer(env, mouse->PositionInWidget().x, mouse->PositionInWidget().y);
72 Inject(env, Action::HoverExit, gesture->TimeStampSeconds()); 72 Inject(env, Action::HoverExit, gesture->TimeStampSeconds());
73 break; 73 break;
74 case blink::WebMouseEvent::kMouseDown:
75 // Mouse down events are translated into touch events on Android anyways,
76 // so we can just send touch events.
77 // We intentionally don't support long press or drags/swipes with mouse
78 // input as this could trigger long press and open 2D popups.
79 SetPointer(env, mouse->PositionInWidget().x, mouse->PositionInWidget().y);
80 Inject(env, Action::Start, gesture->TimeStampSeconds());
81 Inject(env, Action::End, gesture->TimeStampSeconds());
82 break;
83 case blink::WebMouseEvent::kMouseUp:
84 // No need to do anything for mouseUp as mouseDown already handled up.
85 break;
74 default: 86 default:
75 NOTREACHED(); 87 NOTREACHED() << "Unsupported event type sent to Android UI.";
76 break; 88 break;
77 } 89 }
78 } 90 }
79 91
80 void AndroidUiGestureTarget::SetPointer(JNIEnv* env, int x, int y) { 92 void AndroidUiGestureTarget::SetPointer(JNIEnv* env, int x, int y) {
81 content::Java_MotionEventSynthesizer_setPointer(env, event_synthesizer_, 0, x, 93 content::Java_MotionEventSynthesizer_setPointer(env, event_synthesizer_, 0, x,
82 y, 0); 94 y, 0);
83 } 95 }
84 96
85 void AndroidUiGestureTarget::SetScrollDeltas(JNIEnv* env, 97 void AndroidUiGestureTarget::SetScrollDeltas(JNIEnv* env,
86 int x, 98 int x,
87 int y, 99 int y,
88 int dx, 100 int dx,
89 int dy) { 101 int dy) {
90 content::Java_MotionEventSynthesizer_setScrollDeltas(env, event_synthesizer_, 102 content::Java_MotionEventSynthesizer_setScrollDeltas(env, event_synthesizer_,
91 x, y, dx, dy); 103 x, y, dx, dy);
92 } 104 }
93 105
94 void AndroidUiGestureTarget::Inject(JNIEnv* env, 106 void AndroidUiGestureTarget::Inject(JNIEnv* env,
95 Action action, 107 Action action,
96 double time_in_seconds) { 108 double time_in_seconds) {
97 content::Java_MotionEventSynthesizer_inject( 109 content::Java_MotionEventSynthesizer_inject(
98 env, event_synthesizer_, static_cast<int>(action), 1, 110 env, event_synthesizer_, static_cast<int>(action), 1,
99 static_cast<int64_t>(time_in_seconds * 1000.0)); 111 static_cast<int64_t>(time_in_seconds * 1000.0));
100 } 112 }
101 113
102 } // namespace vr_shell 114 } // namespace vr_shell
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698