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

Side by Side Diff: remoting/android/java/src/org/chromium/chromoting/TrackpadInputStrategy.java

Issue 1687873002: Revert of Refactor Chromoting JNI code to use jni/Client (Java changes only). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 package org.chromium.chromoting; 5 package org.chromium.chromoting;
6 6
7 import android.graphics.Point; 7 import android.graphics.Point;
8 import android.view.MotionEvent; 8 import android.view.MotionEvent;
9 9
10 import org.chromium.chromoting.jni.Client; 10 import org.chromium.chromoting.jni.JniInterface;
11 11
12 /** 12 /**
13 * Defines a set of behavior and methods to simulate trackpad behavior when resp onding to 13 * Defines a set of behavior and methods to simulate trackpad behavior when resp onding to
14 * local input event data. This class is also responsible for forwarding input event data 14 * local input event data. This class is also responsible for forwarding input event data
15 * to the remote host for injection there. 15 * to the remote host for injection there.
16 */ 16 */
17 public class TrackpadInputStrategy implements InputStrategyInterface { 17 public class TrackpadInputStrategy implements InputStrategyInterface {
18 private final RenderData mRenderData; 18 private final RenderData mRenderData;
19 private final Client mClient;
20 19
21 /** Mouse-button currently held down, or BUTTON_UNDEFINED otherwise. */ 20 /** Mouse-button currently held down, or BUTTON_UNDEFINED otherwise. */
22 private int mHeldButton = TouchInputHandlerInterface.BUTTON_UNDEFINED; 21 private int mHeldButton = TouchInputHandlerInterface.BUTTON_UNDEFINED;
23 22
24 public TrackpadInputStrategy(RenderData renderData, Client client) { 23 public TrackpadInputStrategy(RenderData renderData) {
25 mRenderData = renderData; 24 mRenderData = renderData;
26 mClient = client;
27 25
28 synchronized (mRenderData) { 26 synchronized (mRenderData) {
29 mRenderData.drawCursor = true; 27 mRenderData.drawCursor = true;
30 } 28 }
31 } 29 }
32 30
33 @Override 31 @Override
34 public boolean onTap(int button) { 32 public boolean onTap(int button) {
35 injectMouseButtonEvent(button, true); 33 injectMouseButtonEvent(button, true);
36 injectMouseButtonEvent(button, false); 34 injectMouseButtonEvent(button, false);
37 return true; 35 return true;
38 } 36 }
39 37
40 @Override 38 @Override
41 public boolean onPressAndHold(int button) { 39 public boolean onPressAndHold(int button) {
42 injectMouseButtonEvent(button, true); 40 injectMouseButtonEvent(button, true);
43 mHeldButton = button; 41 mHeldButton = button;
44 return true; 42 return true;
45 } 43 }
46 44
47 @Override 45 @Override
48 public void onScroll(float distanceX, float distanceY) { 46 public void onScroll(float distanceX, float distanceY) {
49 mClient.sendMouseWheelEvent((int) -distanceX, (int) -distanceY); 47 JniInterface.sendMouseWheelEvent((int) -distanceX, (int) -distanceY);
50 } 48 }
51 49
52 @Override 50 @Override
53 public void onMotionEvent(MotionEvent event) { 51 public void onMotionEvent(MotionEvent event) {
54 if (event.getActionMasked() == MotionEvent.ACTION_UP 52 if (event.getActionMasked() == MotionEvent.ACTION_UP
55 && mHeldButton != TouchInputHandlerInterface.BUTTON_UNDEFINED) { 53 && mHeldButton != TouchInputHandlerInterface.BUTTON_UNDEFINED) {
56 injectMouseButtonEvent(mHeldButton, false); 54 injectMouseButtonEvent(mHeldButton, false);
57 mHeldButton = TouchInputHandlerInterface.BUTTON_UNDEFINED; 55 mHeldButton = TouchInputHandlerInterface.BUTTON_UNDEFINED;
58 } 56 }
59 } 57 }
60 58
61 @Override 59 @Override
62 public void injectCursorMoveEvent(int x, int y) { 60 public void injectCursorMoveEvent(int x, int y) {
63 mClient.sendMouseEvent(x, y, TouchInputHandlerInterface.BUTTON_UNDEFINED , false); 61 JniInterface.sendMouseEvent(x, y, TouchInputHandlerInterface.BUTTON_UNDE FINED, false);
64 } 62 }
65 63
66 @Override 64 @Override
67 public DesktopView.InputFeedbackType getShortPressFeedbackType() { 65 public DesktopView.InputFeedbackType getShortPressFeedbackType() {
68 return DesktopView.InputFeedbackType.NONE; 66 return DesktopView.InputFeedbackType.NONE;
69 } 67 }
70 68
71 @Override 69 @Override
72 public DesktopView.InputFeedbackType getLongPressFeedbackType() { 70 public DesktopView.InputFeedbackType getLongPressFeedbackType() {
73 return DesktopView.InputFeedbackType.SMALL_ANIMATION; 71 return DesktopView.InputFeedbackType.SMALL_ANIMATION;
74 } 72 }
75 73
76 @Override 74 @Override
77 public boolean isIndirectInputMode() { 75 public boolean isIndirectInputMode() {
78 return true; 76 return true;
79 } 77 }
80 78
81 private void injectMouseButtonEvent(int button, boolean pressed) { 79 private void injectMouseButtonEvent(int button, boolean pressed) {
82 Point cursorPosition; 80 Point cursorPosition;
83 synchronized (mRenderData) { 81 synchronized (mRenderData) {
84 cursorPosition = mRenderData.getCursorPosition(); 82 cursorPosition = mRenderData.getCursorPosition();
85 } 83 }
86 mClient.sendMouseEvent(cursorPosition.x, cursorPosition.y, button, press ed); 84 JniInterface.sendMouseEvent(cursorPosition.x, cursorPosition.y, button, pressed);
87 } 85 }
88 } 86 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698