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

Side by Side Diff: remoting/android/java/src/org/chromium/chromoting/TouchInputStrategy.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.Matrix; 7 import android.graphics.Matrix;
8 import android.view.MotionEvent; 8 import android.view.MotionEvent;
9 9
10 import org.chromium.base.VisibleForTesting; 10 import org.chromium.base.VisibleForTesting;
11 import org.chromium.chromoting.jni.Client; 11 import org.chromium.chromoting.jni.JniInterface;
12 import org.chromium.chromoting.jni.TouchEventData; 12 import org.chromium.chromoting.jni.TouchEventData;
13 13
14 import java.util.ArrayList; 14 import java.util.ArrayList;
15 import java.util.LinkedList; 15 import java.util.LinkedList;
16 import java.util.List; 16 import java.util.List;
17 import java.util.Queue; 17 import java.util.Queue;
18 18
19 /** 19 /**
20 * This class receives local touch input events and forwards them to the remote host. 20 * This class receives local touch input events and forwards them to the remote host.
21 * A queue of MotionEvents is built up and then either transmitted to the remote host if one of its 21 * A queue of MotionEvents is built up and then either transmitted to the remote host if one of its
22 * remote gesture handler methods is called (such as onScroll) or it is cleared if the current 22 * remote gesture handler methods is called (such as onScroll) or it is cleared if the current
23 * stream of events does not represent a remote gesture. 23 * stream of events does not represent a remote gesture.
24 * NOTE: Not all touch gestures are remoted. Touch input and gestures outside t he supported ones 24 * NOTE: Not all touch gestures are remoted. Touch input and gestures outside t he supported ones
25 * (which includes tapping and 2 finger panning) will either affect the lo cal canvas or 25 * (which includes tapping and 2 finger panning) will either affect the lo cal canvas or
26 * will be dropped/ignored. 26 * will be dropped/ignored.
27 */ 27 */
28 public class TouchInputStrategy implements InputStrategyInterface { 28 public class TouchInputStrategy implements InputStrategyInterface {
29 /** 29 /**
30 * This interface abstracts the injection mechanism to allow for unit testin g. 30 * This interface abstracts the injection mechanism to allow for unit testin g.
31 */ 31 */
32 public interface RemoteInputInjector { 32 public interface RemoteInputInjector {
33 public void injectMouseEvent(int x, int y, int button, boolean buttonDow n); 33 public void injectMouseEvent(int x, int y, int button, boolean buttonDow n);
34 public void injectTouchEvent(TouchEventData.EventType eventType, TouchEv entData[] data); 34 public void injectTouchEvent(TouchEventData.EventType eventType, TouchEv entData[] data);
35 } 35 }
36 36
37 /** 37 /**
38 * This class provides the default implementation for injecting remote event s. 38 * This class provides the default implementation for injecting remote event s.
39 */ 39 */
40 private class DefaultInputInjector implements RemoteInputInjector { 40 private static class DefaultInputInjector implements RemoteInputInjector {
41 @Override 41 @Override
42 public void injectMouseEvent(int x, int y, int button, boolean buttonDow n) { 42 public void injectMouseEvent(int x, int y, int button, boolean buttonDow n) {
43 mClient.sendMouseEvent(x, y, button, buttonDown); 43 JniInterface.sendMouseEvent(x, y, button, buttonDown);
44 } 44 }
45 45
46 @Override 46 @Override
47 public void injectTouchEvent(TouchEventData.EventType eventType, TouchEv entData[] data) { 47 public void injectTouchEvent(TouchEventData.EventType eventType, TouchEv entData[] data) {
48 mClient.sendTouchEvent(eventType, data); 48 JniInterface.sendTouchEvent(eventType, data);
49 } 49 }
50 } 50 }
51 51
52 /** 52 /**
53 * Contains the maximum number of MotionEvents to store before cancelling th e current gesture. 53 * Contains the maximum number of MotionEvents to store before cancelling th e current gesture.
54 * The size is ~3x the largest number of events seen during any remotable ge sture sequence. 54 * The size is ~3x the largest number of events seen during any remotable ge sture sequence.
55 */ 55 */
56 private static final int QUEUED_EVENT_THRESHOLD = 50; 56 private static final int QUEUED_EVENT_THRESHOLD = 50;
57 57
58 /** 58 /**
(...skipping 11 matching lines...) Expand all
70 private boolean mInRemoteGesture = false; 70 private boolean mInRemoteGesture = false;
71 71
72 /** 72 /**
73 * Indicates whether MotionEvents and gestures should be acted upon or ignor ed. This flag is 73 * Indicates whether MotionEvents and gestures should be acted upon or ignor ed. This flag is
74 * set when we believe that the current sequence of events is not something we should remote. 74 * set when we believe that the current sequence of events is not something we should remote.
75 */ 75 */
76 private boolean mIgnoreTouchEvents = false; 76 private boolean mIgnoreTouchEvents = false;
77 77
78 private final RenderData mRenderData; 78 private final RenderData mRenderData;
79 79
80 private final Client mClient;
81
82 private RemoteInputInjector mRemoteInputInjector; 80 private RemoteInputInjector mRemoteInputInjector;
83 81
84 public TouchInputStrategy(RenderData renderData, Client client) { 82 public TouchInputStrategy(RenderData renderData) {
85 mRenderData = renderData; 83 mRenderData = renderData;
86 mClient = client;
87 mRemoteInputInjector = new DefaultInputInjector(); 84 mRemoteInputInjector = new DefaultInputInjector();
88 mQueuedEvents = new LinkedList<MotionEvent>(); 85 mQueuedEvents = new LinkedList<MotionEvent>();
89 86
90 synchronized (mRenderData) { 87 synchronized (mRenderData) {
91 mRenderData.drawCursor = false; 88 mRenderData.drawCursor = false;
92 } 89 }
93 } 90 }
94 91
95 @Override 92 @Override
96 public boolean onTap(int button) { 93 public boolean onTap(int button) {
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 307
311 return event; 308 return event;
312 } 309 }
313 310
314 private void resetStateData() { 311 private void resetStateData() {
315 clearQueuedEvents(); 312 clearQueuedEvents();
316 mInRemoteGesture = false; 313 mInRemoteGesture = false;
317 mIgnoreTouchEvents = false; 314 mIgnoreTouchEvents = false;
318 } 315 }
319 } 316 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698