diff options
| author | Michael Wright <michaelwr@google.com> | 2013-04-23 11:16:08 -0700 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2013-04-23 11:16:08 -0700 |
| commit | 058feb4e1d18bc1fcedac019d2364ebfd9a4c383 (patch) | |
| tree | a645ba7c868d254cc861eb18b5a23cd545ceee88 /core/java/android/view/ViewRootImpl.java | |
| parent | 7ac47e8acba4d352ac2971d46589c03dad45436a (diff) | |
| parent | 585000515faacc02736f920425ae6c323223ee58 (diff) | |
am 58500051: am 5fe6e4c4: Merge "Rewrite input handling for native applications" into jb-mr2-dev
* commit '585000515faacc02736f920425ae6c323223ee58':
Rewrite input handling for native applications
Diffstat (limited to 'core/java/android/view/ViewRootImpl.java')
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 64 |
1 files changed, 47 insertions, 17 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 3215e21e1b1f..f34d390137b3 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -600,12 +600,11 @@ public final class ViewRootImpl implements ViewParent, } if (mInputChannel != null) { if (mInputQueueCallback != null) { - mInputQueue = new InputQueue(mInputChannel); + mInputQueue = new InputQueue(); mInputQueueCallback.onInputQueueCreated(mInputQueue); - } else { - mInputEventReceiver = new WindowInputEventReceiver(mInputChannel, - Looper.myLooper()); } + mInputEventReceiver = new WindowInputEventReceiver(mInputChannel, + Looper.myLooper()); } view.assignParent(this); @@ -2825,9 +2824,11 @@ public final class ViewRootImpl implements ViewParent, if (mInputQueueCallback != null && mInputQueue != null) { mInputQueueCallback.onInputQueueDestroyed(mInputQueue); + mInputQueue.dispose(); mInputQueueCallback = null; mInputQueue = null; - } else if (mInputEventReceiver != null) { + } + if (mInputEventReceiver != null) { mInputEventReceiver.dispose(); mInputEventReceiver = null; } @@ -3350,6 +3351,15 @@ public final class ViewRootImpl implements ViewParent, if ((q.mFlags & QueuedInputEvent.FLAG_FINISHED) != 0) { forward(q); } else if (mView == null || !mAdded) { + Slog.w(TAG, "Dropping event due to root view being removed: " + q.mEvent); + finish(q, false); + } else if (!mAttachInfo.mHasWindowFocus && + !q.mEvent.isFromSource(InputDevice.SOURCE_CLASS_POINTER) && + !isTerminalInputEvent(q.mEvent)) { + // If this is a focused event and the window doesn't currently have input focus, + // then drop this event. This could be an event that came back from the previous + // stage but the window has lost focus in the meantime. + Slog.w(TAG, "Dropping event due to no window focus: " + q.mEvent); finish(q, false); } else { apply(q, onProcess(q)); @@ -3550,15 +3560,30 @@ public final class ViewRootImpl implements ViewParent, * Delivers pre-ime input events to a native activity. * Does not support pointer events. */ - final class NativePreImeInputStage extends AsyncInputStage { + final class NativePreImeInputStage extends AsyncInputStage + implements InputQueue.FinishedInputEventCallback { public NativePreImeInputStage(InputStage next, String traceCounter) { super(next, traceCounter); } @Override protected int onProcess(QueuedInputEvent q) { + if (mInputQueue != null && q.mEvent instanceof KeyEvent) { + mInputQueue.sendInputEvent(q.mEvent, q, true, this); + return DEFER; + } return FORWARD; } + + @Override + public void onFinishedInputEvent(Object token, boolean handled) { + QueuedInputEvent q = (QueuedInputEvent)token; + if (handled) { + finish(q, true); + return; + } + forward(q); + } } /** @@ -3624,16 +3649,6 @@ public final class ViewRootImpl implements ViewParent, finish(q, true); return; } - - // If the window doesn't currently have input focus, then drop - // this event. This could be an event that came back from the - // IME dispatch but the window has lost focus in the meantime. - if (!mAttachInfo.mHasWindowFocus && !isTerminalInputEvent(q.mEvent)) { - Slog.w(TAG, "Dropping event due to no window focus: " + q.mEvent); - finish(q, false); - return; - } - forward(q); } } @@ -3705,15 +3720,30 @@ public final class ViewRootImpl implements ViewParent, /** * Delivers post-ime input events to a native activity. */ - final class NativePostImeInputStage extends AsyncInputStage { + final class NativePostImeInputStage extends AsyncInputStage + implements InputQueue.FinishedInputEventCallback { public NativePostImeInputStage(InputStage next, String traceCounter) { super(next, traceCounter); } @Override protected int onProcess(QueuedInputEvent q) { + if (mInputQueue != null) { + mInputQueue.sendInputEvent(q.mEvent, q, false, this); + return DEFER; + } return FORWARD; } + + @Override + public void onFinishedInputEvent(Object token, boolean handled) { + QueuedInputEvent q = (QueuedInputEvent)token; + if (handled) { + finish(q, true); + return; + } + forward(q); + } } /** |
