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

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

Issue 2047903002: [Chromoting] TouchInputHandler now listens to events in DesktopView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve review comments Created 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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.content.Context; 7 import android.content.Context;
8 import android.graphics.Bitmap; 8 import android.graphics.Bitmap;
9 import android.graphics.Canvas; 9 import android.graphics.Canvas;
10 import android.graphics.Color; 10 import android.graphics.Color;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 // be dropped if this is already set to true. This is used by the main threa d and the painting 51 // be dropped if this is already set to true. This is used by the main threa d and the painting
52 // thread, so the access should be synchronized on |mRenderData|. 52 // thread, so the access should be synchronized on |mRenderData|.
53 private boolean mRepaintPending; 53 private boolean mRepaintPending;
54 54
55 // Flag used to ensure that the SurfaceView is only painted between calls to surfaceCreated() 55 // Flag used to ensure that the SurfaceView is only painted between calls to surfaceCreated()
56 // and surfaceDestroyed(). Accessed on main thread and display thread, so th is should be 56 // and surfaceDestroyed(). Accessed on main thread and display thread, so th is should be
57 // synchronized on |mRenderData|. 57 // synchronized on |mRenderData|.
58 private boolean mSurfaceCreated = false; 58 private boolean mSurfaceCreated = false;
59 59
60 private final Event.Raisable<PaintEventParameter> mOnPaint = new Event.Raisa ble<>(); 60 private final Event.Raisable<PaintEventParameter> mOnPaint = new Event.Raisa ble<>();
61 private final Event.Raisable<SizeChangedEventParameter> mOnClientSizeChanged =
62 new Event.Raisable<>();
63 private final Event.Raisable<SizeChangedEventParameter> mOnHostSizeChanged =
64 new Event.Raisable<>();
65 private final Event.Raisable<TouchEventParameter> mOnTouch = new Event.Raisa ble<>();
61 66
62 // Variables to control animation by the TouchInputHandler. 67 // Variables to control animation by the TouchInputHandler.
63 68
64 /** Protects mInputAnimationRunning. */ 69 /** Protects mInputAnimationRunning. */
65 private final Object mAnimationLock = new Object(); 70 private final Object mAnimationLock = new Object();
66 71
67 /** Whether the TouchInputHandler has requested animation to be performed. * / 72 /** Whether the TouchInputHandler has requested animation to be performed. * /
68 private boolean mInputAnimationRunning = false; 73 private boolean mInputAnimationRunning = false;
69 74
70 public DesktopView(Context context, AttributeSet attributes) { 75 public DesktopView(Context context, AttributeSet attributes) {
(...skipping 18 matching lines...) Expand all
89 Preconditions.notNull(client); 94 Preconditions.notNull(client);
90 mDesktop = desktop; 95 mDesktop = desktop;
91 mClient = client; 96 mClient = client;
92 mInputHandler.init(desktop, client); 97 mInputHandler.init(desktop, client);
93 } 98 }
94 99
95 public Event<PaintEventParameter> onPaint() { 100 public Event<PaintEventParameter> onPaint() {
96 return mOnPaint; 101 return mOnPaint;
97 } 102 }
98 103
104 public Event<SizeChangedEventParameter> onClientSizeChanged() {
105 return mOnClientSizeChanged;
106 }
107
108 public Event<SizeChangedEventParameter> onHostSizeChanged() {
109 return mOnHostSizeChanged;
110 }
111
112 public Event<TouchEventParameter> onTouch() {
113 return mOnTouch;
114 }
115
99 /** Request repainting of the desktop view. */ 116 /** Request repainting of the desktop view. */
100 void requestRepaint() { 117 void requestRepaint() {
101 synchronized (mRenderData) { 118 synchronized (mRenderData) {
102 if (mRepaintPending) { 119 if (mRepaintPending) {
103 return; 120 return;
104 } 121 }
105 mRepaintPending = true; 122 mRepaintPending = true;
106 } 123 }
107 mClient.getDisplay().redrawGraphics(); 124 mClient.getDisplay().redrawGraphics();
108 } 125 }
(...skipping 24 matching lines...) Expand all
133 if (mRenderData.imageWidth != width || mRenderData.imageHeight != he ight) { 150 if (mRenderData.imageWidth != width || mRenderData.imageHeight != he ight) {
134 // TODO(lambroslambrou): Move this code into a sizeChanged() cal lback, to be 151 // TODO(lambroslambrou): Move this code into a sizeChanged() cal lback, to be
135 // triggered from native code (on the display thread) when the r emote screen size 152 // triggered from native code (on the display thread) when the r emote screen size
136 // changes. 153 // changes.
137 mRenderData.imageWidth = width; 154 mRenderData.imageWidth = width;
138 mRenderData.imageHeight = height; 155 mRenderData.imageHeight = height;
139 sizeChanged = true; 156 sizeChanged = true;
140 } 157 }
141 } 158 }
142 if (sizeChanged) { 159 if (sizeChanged) {
143 mInputHandler.onHostSizeChanged(width, height); 160 mOnHostSizeChanged.raise(new SizeChangedEventParameter(width, height ));
144 } 161 }
145 162
146 Canvas canvas; 163 Canvas canvas;
147 Point cursorPosition; 164 Point cursorPosition;
148 boolean drawCursor; 165 boolean drawCursor;
149 synchronized (mRenderData) { 166 synchronized (mRenderData) {
150 mRepaintPending = false; 167 mRepaintPending = false;
151 // Don't try to lock the canvas before it is ready, as the implement ation of 168 // Don't try to lock the canvas before it is ready, as the implement ation of
152 // lockCanvas() may throttle these calls to a slow rate in order to avoid consuming CPU. 169 // lockCanvas() may throttle these calls to a slow rate in order to avoid consuming CPU.
153 // Note that a successful call to lockCanvas() will prevent the fram ework from 170 // Note that a successful call to lockCanvas() will prevent the fram ework from
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 * the display is rotated. 233 * the display is rotated.
217 */ 234 */
218 @Override 235 @Override
219 public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { 236 public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
220 synchronized (mRenderData) { 237 synchronized (mRenderData) {
221 mRenderData.screenWidth = width; 238 mRenderData.screenWidth = width;
222 mRenderData.screenHeight = height; 239 mRenderData.screenHeight = height;
223 } 240 }
224 241
225 attachRedrawCallback(); 242 attachRedrawCallback();
226 mInputHandler.onClientSizeChanged(width, height); 243 mOnClientSizeChanged.raise(new SizeChangedEventParameter(width, height)) ;
227 requestRepaint(); 244 requestRepaint();
228 } 245 }
229 246
230 public void attachRedrawCallback() { 247 public void attachRedrawCallback() {
231 mClient.getDisplay().provideRedrawCallback(new Runnable() { 248 mClient.getDisplay().provideRedrawCallback(new Runnable() {
232 @Override 249 @Override
233 public void run() { 250 public void run() {
234 paint(); 251 paint();
235 } 252 }
236 }); 253 });
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 286
270 // Stops software keyboards from closing as soon as the enter key is pre ssed. 287 // Stops software keyboards from closing as soon as the enter key is pre ssed.
271 outAttrs.imeOptions |= EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_ NO_ENTER_ACTION; 288 outAttrs.imeOptions |= EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_ NO_ENTER_ACTION;
272 289
273 return null; 290 return null;
274 } 291 }
275 292
276 /** Called whenever the user attempts to touch the canvas. */ 293 /** Called whenever the user attempts to touch the canvas. */
277 @Override 294 @Override
278 public boolean onTouchEvent(MotionEvent event) { 295 public boolean onTouchEvent(MotionEvent event) {
279 return mInputHandler.onTouchEvent(event); 296 TouchEventParameter parameter = new TouchEventParameter(event);
297 mOnTouch.raise(parameter);
298 return parameter.handled;
280 } 299 }
281 300
282 @Override 301 @Override
283 public void showInputFeedback(InputFeedbackType feedbackToShow, Point pos) { 302 public void showInputFeedback(InputFeedbackType feedbackToShow, Point pos) {
284 if (feedbackToShow != InputFeedbackType.NONE) { 303 if (feedbackToShow != InputFeedbackType.NONE) {
285 FeedbackAnimator.startAnimation(this, pos, feedbackToShow); 304 FeedbackAnimator.startAnimation(this, pos, feedbackToShow);
286 requestRepaint(); 305 requestRepaint();
287 } 306 }
288 } 307 }
289 308
(...skipping 17 matching lines...) Expand all
307 @Override 326 @Override
308 public void setAnimationEnabled(boolean enabled) { 327 public void setAnimationEnabled(boolean enabled) {
309 synchronized (mAnimationLock) { 328 synchronized (mAnimationLock) {
310 if (enabled && !mInputAnimationRunning) { 329 if (enabled && !mInputAnimationRunning) {
311 requestRepaint(); 330 requestRepaint();
312 } 331 }
313 mInputAnimationRunning = enabled; 332 mInputAnimationRunning = enabled;
314 } 333 }
315 } 334 }
316 } 335 }
OLDNEW
« no previous file with comments | « remoting/android/client_java_tmpl.gni ('k') | remoting/android/java/src/org/chromium/chromoting/DesktopViewInterface.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698