@@ -204,6 +204,10 @@ public void run() {
204
204
if (mScroller .isFinished ()) {
205
205
return ;
206
206
}
207
+ // Check whether mouse tracking was turned on during fling.
208
+ if (mouseTrackingActive ()) {
209
+ return ;
210
+ }
207
211
208
212
boolean more = mScroller .computeScrollOffset ();
209
213
int newTopRow = mScroller .getCurrY ();
@@ -218,6 +222,47 @@ public void run() {
218
222
219
223
}
220
224
};
225
+
226
+ private class MouseTrackerFlingRunner implements Runnable {
227
+ private Scroller mScroller ;
228
+ private int mLastY ;
229
+ private MotionEvent mMotionEvent ;
230
+
231
+ public void fling (MotionEvent e , float velocityX , float velocityY ) {
232
+ float SCALE = 0.15f ;
233
+ mScroller .fling (0 , 0 ,
234
+ -(int ) (velocityX * SCALE ), -(int ) (velocityY * SCALE ),
235
+ 0 , 0 , -100 , 100 );
236
+ mLastY = 0 ;
237
+ mMotionEvent = e ;
238
+ post (this );
239
+ }
240
+
241
+ public void run () {
242
+ if (mScroller .isFinished ()) {
243
+ return ;
244
+ }
245
+ // Check whether mouse tracking was turned off during fling.
246
+ if (!mouseTrackingActive ()) {
247
+ return ;
248
+ }
249
+
250
+ boolean more = mScroller .computeScrollOffset ();
251
+ int newY = mScroller .getCurrY ();
252
+ for (; mLastY < newY ; mLastY ++) {
253
+ sendMouseEventCode (mMotionEvent , 65 );
254
+ }
255
+ for (; mLastY > newY ; mLastY --) {
256
+ sendMouseEventCode (mMotionEvent , 64 );
257
+ }
258
+
259
+ if (more ) {
260
+ post (this );
261
+ }
262
+ }
263
+ };
264
+ private MouseTrackerFlingRunner mMouseTrackerFlingRunner = new MouseTrackerFlingRunner ();
265
+
221
266
private float mScrollRemainder ;
222
267
private TermKeyListener mKeyListener ;
223
268
@@ -288,6 +333,7 @@ public EmulatorView(Context context, AttributeSet attrs, int defStyle) {
288
333
private void commonConstructor (Context context ) {
289
334
// TODO: See if we want to use the API level 11 constructor to get new flywheel feature.
290
335
mScroller = new Scroller (context );
336
+ mMouseTrackerFlingRunner .mScroller = new Scroller (context );
291
337
}
292
338
293
339
/**
@@ -917,16 +963,18 @@ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
917
963
return true ;
918
964
}
919
965
920
- // XXX - handle mouse tracking
921
-
922
- float SCALE = 0.25f ;
923
- mScroller .fling (0 , mTopRow ,
924
- -(int ) (velocityX * SCALE ), -(int ) (velocityY * SCALE ),
925
- 0 , 0 ,
926
- -mTranscriptScreen .getActiveTranscriptRows (), 0 );
927
966
mScrollRemainder = 0.0f ;
928
- // onScroll(e1, e2, 0.1f * velocityX, -0.1f * velocityY);
929
- post (mFlingRunner );
967
+ if (mouseTrackingActive ()) {
968
+ mMouseTrackerFlingRunner .fling (e1 , velocityX , velocityY );
969
+ } else {
970
+ float SCALE = 0.25f ;
971
+ mScroller .fling (0 , mTopRow ,
972
+ -(int ) (velocityX * SCALE ), -(int ) (velocityY * SCALE ),
973
+ 0 , 0 ,
974
+ -mTranscriptScreen .getActiveTranscriptRows (), 0 );
975
+ // onScroll(e1, e2, 0.1f * velocityX, -0.1f * velocityY);
976
+ post (mFlingRunner );
977
+ }
930
978
return true ;
931
979
}
932
980
0 commit comments