diff options
| author | Dianne Hackborn <hackbod@google.com> | 2009-08-17 15:15:18 -0700 |
|---|---|---|
| committer | Dianne Hackborn <hackbod@google.com> | 2009-08-17 21:23:05 -0700 |
| commit | 8df8b2b405c60cacf7a66c4e2ca078dd3d7ec7bd (patch) | |
| tree | 302a410dcd7af7bbf61f435cd96dd8b7384def2e /core/java/android/view/MotionEvent.java | |
| parent | 948ee251276e1ce7f5c5517b24bf88a75e99f160 (diff) | |
Allow wallpapers to get touch events.
Diffstat (limited to 'core/java/android/view/MotionEvent.java')
| -rw-r--r-- | core/java/android/view/MotionEvent.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java index e8bfa6ad40dd..b2f0c60b0b30 100644 --- a/core/java/android/view/MotionEvent.java +++ b/core/java/android/view/MotionEvent.java @@ -552,6 +552,44 @@ public final class MotionEvent implements Parcelable { } /** + * Create a new MotionEvent, copying from an existing one, but not including + * any historical point information. + */ + static public MotionEvent obtainNoHistory(MotionEvent o) { + MotionEvent ev = obtain(); + ev.mDeviceId = o.mDeviceId; + ev.mEdgeFlags = o.mEdgeFlags; + ev.mDownTime = o.mDownTime; + ev.mEventTimeNano = o.mEventTimeNano; + ev.mAction = o.mAction; + ev.mNumPointers = o.mNumPointers; + ev.mRawX = o.mRawX; + ev.mRawY = o.mRawY; + ev.mMetaState = o.mMetaState; + ev.mXPrecision = o.mXPrecision; + ev.mYPrecision = o.mYPrecision; + + ev.mNumSamples = 1; + ev.mTimeSamples[0] = o.mTimeSamples[0]; + + final int NP = (ev.mNumPointers=o.mNumPointers); + if (ev.mPointerIdentifiers.length >= NP) { + System.arraycopy(o.mPointerIdentifiers, 0, ev.mPointerIdentifiers, 0, NP); + } else { + ev.mPointerIdentifiers = (int[])o.mPointerIdentifiers.clone(); + } + + final int ND = NP * NUM_SAMPLE_DATA; + if (ev.mDataSamples.length >= ND) { + System.arraycopy(o.mDataSamples, 0, ev.mDataSamples, 0, ND); + } else { + ev.mDataSamples = (float[])o.mDataSamples.clone(); + } + + return ev; + } + + /** * Recycle the MotionEvent, to be re-used by a later caller. After calling * this function you must not ever touch the event again. */ |
