Track focus changes on external displays (2/4)
Let each DisplayContent has its own focused window and focused app.
This change also moves the last tapped display to the top.
Test: atest ActivityManagerMultiDisplayTests
ActivityStackSupervisorTests
ActivityStackTests
CtsWindowManagerDeviceTestCases
DisplayContentTests
PointerCaptureTest
Bug: 111361570
Change-Id: I776cabaeaf41ff4240f504fb1430d3e40892023d
diff --git a/services/core/java/com/android/server/input/InputManagerService.java b/services/core/java/com/android/server/input/InputManagerService.java
index 5bd095d..4913e8b 100644
--- a/services/core/java/com/android/server/input/InputManagerService.java
+++ b/services/core/java/com/android/server/input/InputManagerService.java
@@ -209,7 +209,8 @@
private static native void nativeSetInputDispatchMode(long ptr, boolean enabled, boolean frozen);
private static native void nativeSetSystemUiVisibility(long ptr, int visibility);
private static native void nativeSetFocusedApplication(long ptr,
- InputApplicationHandle application);
+ int displayId, InputApplicationHandle application);
+ private static native void nativeSetFocusedDisplay(long ptr, int displayId);
private static native boolean nativeTransferTouchFocus(long ptr,
InputChannel fromChannel, InputChannel toChannel);
private static native void nativeSetPointerSpeed(long ptr, int speed);
@@ -1431,21 +1432,27 @@
}
}
- public void setInputWindows(InputWindowHandle[] windowHandles,
- InputWindowHandle focusedWindowHandle, int displayId) {
- final IWindow newFocusedWindow =
- focusedWindowHandle != null ? focusedWindowHandle.clientWindow : null;
- if (mFocusedWindow != newFocusedWindow) {
- mFocusedWindow = newFocusedWindow;
- if (mFocusedWindowHasCapture) {
- setPointerCapture(false);
- }
- }
+ public void setInputWindows(InputWindowHandle[] windowHandles, int displayId) {
nativeSetInputWindows(mPtr, windowHandles, displayId);
}
- public void setFocusedApplication(InputApplicationHandle application) {
- nativeSetFocusedApplication(mPtr, application);
+ public void setFocusedApplication(int displayId, InputApplicationHandle application) {
+ nativeSetFocusedApplication(mPtr, displayId, application);
+ }
+
+ public void setFocusedWindow(InputWindowHandle focusedWindowHandle) {
+ final IWindow newFocusedWindow =
+ focusedWindowHandle != null ? focusedWindowHandle.clientWindow : null;
+ if (mFocusedWindow != newFocusedWindow) {
+ if (mFocusedWindowHasCapture) {
+ setPointerCapture(false);
+ }
+ mFocusedWindow = newFocusedWindow;
+ }
+ }
+
+ public void setFocusedDisplay(int displayId) {
+ nativeSetFocusedDisplay(mPtr, displayId);
}
@Override
@@ -1460,16 +1467,18 @@
return;
}
setPointerCapture(enabled);
- try {
- mFocusedWindow.dispatchPointerCaptureChanged(enabled);
- } catch (RemoteException ex) {
- /* ignore */
- }
}
private void setPointerCapture(boolean enabled) {
- mFocusedWindowHasCapture = enabled;
- nativeSetPointerCapture(mPtr, enabled);
+ if (mFocusedWindowHasCapture != enabled) {
+ mFocusedWindowHasCapture = enabled;
+ try {
+ mFocusedWindow.dispatchPointerCaptureChanged(enabled);
+ } catch (RemoteException ex) {
+ /* ignore */
+ }
+ nativeSetPointerCapture(mPtr, enabled);
+ }
}
public void setInputDispatchMode(boolean enabled, boolean frozen) {