Tell system server whether the app handled input events.
Refactored ViewRoot, NativeActivity and related classes to tell the dispatcher whether an input event was actually handled by the application. This will be used to move more of the global default key processing into the system server instead of the application. Change-Id: If06b98b6f45c543e5ac5b1eae2b3baf9371fba28
This commit is contained in:
@ -824,13 +824,15 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
DragState mDragState = null;
|
||||
private final InputHandler mDragInputHandler = new BaseInputHandler() {
|
||||
@Override
|
||||
public void handleMotion(MotionEvent event, Runnable finishedCallback) {
|
||||
boolean endDrag = false;
|
||||
final float newX = event.getRawX();
|
||||
final float newY = event.getRawY();
|
||||
|
||||
public void handleMotion(MotionEvent event, InputQueue.FinishedCallback finishedCallback) {
|
||||
boolean handled = false;
|
||||
try {
|
||||
if (mDragState != null) {
|
||||
if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0
|
||||
&& mDragState != null) {
|
||||
boolean endDrag = false;
|
||||
final float newX = event.getRawX();
|
||||
final float newY = event.getRawY();
|
||||
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN: {
|
||||
if (DEBUG_DRAG) {
|
||||
@ -866,11 +868,13 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
mDragState.endDragLw();
|
||||
}
|
||||
}
|
||||
|
||||
handled = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Slog.e(TAG, "Exception caught by drag handleMotion", e);
|
||||
} finally {
|
||||
finishedCallback.run();
|
||||
finishedCallback.finished(handled);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -5781,6 +5785,16 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
keyCode, scanCode, metaState, repeatCount, policyFlags);
|
||||
}
|
||||
|
||||
/* Provides an opportunity for the window manager policy to process a key that
|
||||
* the application did not handle. */
|
||||
public boolean dispatchUnhandledKey(InputChannel focus,
|
||||
int action, int flags, int keyCode, int scanCode, int metaState, int repeatCount,
|
||||
int policyFlags) {
|
||||
WindowState windowState = getWindowStateForInputChannel(focus);
|
||||
return mPolicy.dispatchUnhandledKey(windowState, action, flags,
|
||||
keyCode, scanCode, metaState, repeatCount, policyFlags);
|
||||
}
|
||||
|
||||
/* Called when the current input focus changes.
|
||||
* Layer assignment is assumed to be complete by the time this is called.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user