OLD | NEW |
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.app.ActionBar; | 7 import android.app.ActionBar; |
8 import android.app.Activity; | 8 import android.app.Activity; |
9 import android.graphics.Bitmap; | 9 import android.graphics.Bitmap; |
10 import android.graphics.Canvas; | 10 import android.graphics.Canvas; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 private int mMouseButton; | 79 private int mMouseButton; |
80 private boolean mMousePressed; | 80 private boolean mMousePressed; |
81 | 81 |
82 public DesktopView(Activity context) { | 82 public DesktopView(Activity context) { |
83 super(context); | 83 super(context); |
84 mActionBar = context.getActionBar(); | 84 mActionBar = context.getActionBar(); |
85 | 85 |
86 getHolder().addCallback(this); | 86 getHolder().addCallback(this); |
87 DesktopListener listener = new DesktopListener(); | 87 DesktopListener listener = new DesktopListener(); |
88 mScroller = new GestureDetector(context, listener); | 88 mScroller = new GestureDetector(context, listener, null, false); |
89 mZoomer = new ScaleGestureDetector(context, listener); | 89 mZoomer = new ScaleGestureDetector(context, listener); |
90 | 90 |
91 mTransform = new Matrix(); | 91 mTransform = new Matrix(); |
92 mScreenWidth = 0; | 92 mScreenWidth = 0; |
93 mScreenHeight = 0; | 93 mScreenHeight = 0; |
94 | 94 |
95 mConstraint = Constraint.UNDEFINED; | 95 mConstraint = Constraint.UNDEFINED; |
96 mRecheckConstraint = false; | 96 mRecheckConstraint = false; |
97 | 97 |
98 mRightUsedToBeOut = false; | 98 mRightUsedToBeOut = false; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 // Prevent the user from scrolling past the left or right edge o
f the image. | 172 // Prevent the user from scrolling past the left or right edge o
f the image. |
173 if (leftEdgeOutOfBounds != rightEdgeOutOfBounds) { | 173 if (leftEdgeOutOfBounds != rightEdgeOutOfBounds) { |
174 if (leftEdgeOutOfBounds != mRightUsedToBeOut) { | 174 if (leftEdgeOutOfBounds != mRightUsedToBeOut) { |
175 // Make the left edge of the image flush with the left s
creen edge. | 175 // Make the left edge of the image flush with the left s
creen edge. |
176 values[Matrix.MTRANS_X] = 0; | 176 values[Matrix.MTRANS_X] = 0; |
177 } | 177 } |
178 else { | 178 else { |
179 // Make the right edge of the image flush with the right
screen edge. | 179 // Make the right edge of the image flush with the right
screen edge. |
180 values[Matrix.MTRANS_X] += mScreenWidth - bottomright[0]
; | 180 values[Matrix.MTRANS_X] += mScreenWidth - bottomright[0]
; |
181 } | 181 } |
182 } | 182 } else { |
183 else { | |
184 // The else prevents this from being updated during the repo
sitioning process, | 183 // The else prevents this from being updated during the repo
sitioning process, |
185 // in which case the view would begin to oscillate. | 184 // in which case the view would begin to oscillate. |
186 mRightUsedToBeOut = rightEdgeOutOfBounds; | 185 mRightUsedToBeOut = rightEdgeOutOfBounds; |
187 } | 186 } |
188 | 187 |
189 // Prevent the user from scrolling past the top or bottom edge o
f the image. | 188 // Prevent the user from scrolling past the top or bottom edge o
f the image. |
190 if (topEdgeOutOfBounds != bottomEdgeOutOfBounds) { | 189 if (topEdgeOutOfBounds != bottomEdgeOutOfBounds) { |
191 if (topEdgeOutOfBounds != mBottomUsedToBeOut) { | 190 if (topEdgeOutOfBounds != mBottomUsedToBeOut) { |
192 // Make the top edge of the image flush with the top scr
een edge. | 191 // Make the top edge of the image flush with the top scr
een edge. |
193 values[Matrix.MTRANS_Y] = 0; | 192 values[Matrix.MTRANS_Y] = 0; |
194 } | 193 } else { |
195 else { | |
196 // Make the bottom edge of the image flush with the bott
om screen edge. | 194 // Make the bottom edge of the image flush with the bott
om screen edge. |
197 values[Matrix.MTRANS_Y] += mScreenHeight - bottomright[1
]; | 195 values[Matrix.MTRANS_Y] += mScreenHeight - bottomright[1
]; |
198 } | 196 } |
199 } | 197 } |
200 else { | 198 else { |
201 // The else prevents this from being updated during the repo
sitioning process, | 199 // The else prevents this from being updated during the repo
sitioning process, |
202 // in which case the view would begin to oscillate. | 200 // in which case the view would begin to oscillate. |
203 mBottomUsedToBeOut = bottomEdgeOutOfBounds; | 201 mBottomUsedToBeOut = bottomEdgeOutOfBounds; |
204 } | 202 } |
205 | 203 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 mMouseButton = BUTTON_LEFT; | 305 mMouseButton = BUTTON_LEFT; |
308 mMousePressed = true; | 306 mMousePressed = true; |
309 } | 307 } |
310 break; | 308 break; |
311 | 309 |
312 case MotionEvent.ACTION_UP: | 310 case MotionEvent.ACTION_UP: |
313 Log.i("mouse", "Lost the finger"); | 311 Log.i("mouse", "Lost the finger"); |
314 if (mMouseButton == BUTTON_UNDEFINED) { | 312 if (mMouseButton == BUTTON_UNDEFINED) { |
315 // The user pressed and released without moving: do left
click and release. | 313 // The user pressed and released without moving: do left
click and release. |
316 Log.i("mouse", "\tStarting and finishing left click"); | 314 Log.i("mouse", "\tStarting and finishing left click"); |
317 handleMouseMovement(coordinates, BUTTON_LEFT, true); | 315 handleMouseMovement(new float[] {coordinates[0], coordin
ates[1]}, |
| 316 BUTTON_LEFT, true); |
318 mMouseButton = BUTTON_LEFT; | 317 mMouseButton = BUTTON_LEFT; |
319 mMousePressed = false; | 318 mMousePressed = false; |
320 } | 319 } |
321 else if (mMousePressed) { | 320 else if (mMousePressed) { |
322 Log.i("mouse", "\tReleasing the currently-pressed button
"); | 321 Log.i("mouse", "\tReleasing the currently-pressed button
"); |
323 mMousePressed = false; | 322 mMousePressed = false; |
324 } | 323 } |
325 else { | 324 else { |
326 Log.w("mouse", "Button already in released state before
gesture ended"); | 325 Log.w("mouse", "Button already in released state before
gesture ended"); |
327 } | 326 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 handleMouseMovement(coordinates, mMouseButton, false); | 412 handleMouseMovement(coordinates, mMouseButton, false); |
414 } | 413 } |
415 | 414 |
416 Log.i("mouse", "\tStarting right click"); | 415 Log.i("mouse", "\tStarting right click"); |
417 mMouseButton = BUTTON_RIGHT; | 416 mMouseButton = BUTTON_RIGHT; |
418 mMousePressed = true; | 417 mMousePressed = true; |
419 handleMouseMovement(coordinates, mMouseButton, mMousePressed); | 418 handleMouseMovement(coordinates, mMouseButton, mMousePressed); |
420 } | 419 } |
421 } | 420 } |
422 } | 421 } |
OLD | NEW |