diff options
| author | 2020-05-20 22:05:30 +0000 | |
|---|---|---|
| committer | 2020-05-20 22:05:30 +0000 | |
| commit | 98df02ebacb2b7227e2fda9e95769a0a063601a5 (patch) | |
| tree | d31076f179f1344ffa4b1b29259694e1e28382c0 | |
| parent | 3a2d5379e568d70094b3bf0d46f879278eec2f39 (diff) | |
| parent | 50dbc983bf86727cf29a3e5a55f7ecc75791e506 (diff) | |
Merge "Check embedded windows for IME target" into rvc-dev
| -rw-r--r-- | services/core/java/com/android/server/wm/WindowState.java | 22 | ||||
| -rw-r--r-- | services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java | 20 |
2 files changed, 42 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index fd18e6f9c39a..e9aff88d0f80 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -2262,7 +2262,29 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP mHasSurface = hasSurface; } + /** + * Checks whether one of the Windows in a Display embedded in this Window can be an IME target. + */ + private boolean canWindowInEmbeddedDisplayBeImeTarget() { + final int embeddedDisplayContentsSize = mEmbeddedDisplayContents.size(); + for (int i = embeddedDisplayContentsSize - 1; i >= 0; i--) { + final DisplayContent edc = mEmbeddedDisplayContents.valueAt(i); + if (edc.forAllWindows(WindowState::canBeImeTarget, true)) { + return true; + } + } + return false; + } + boolean canBeImeTarget() { + // If any of the embedded windows can be the IME target, this window will be the final IME + // target. This is because embedded windows are on a different display in WM so it would + // cause confusion trying to set the IME to a window on a different display. Instead, just + // make the host window the IME target. + if (canWindowInEmbeddedDisplayBeImeTarget()) { + return true; + } + if (mIsImWindow) { // IME windows can't be IME targets. IME targets are required to be below the IME // windows and that wouldn't be possible if the IME window is its own target...silly. diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java index 0346329eccd4..8ce5daa635f2 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java @@ -270,6 +270,26 @@ public class WindowStateTests extends WindowTestsBase { } @Test + public void testCanWindowWithEmbeddedDisplayBeImeTarget() { + final WindowState appWindow = createWindow(null, TYPE_APPLICATION, "appWindow"); + final WindowState imeWindow = createWindow(null, TYPE_INPUT_METHOD, "imeWindow"); + + imeWindow.setHasSurface(true); + appWindow.setHasSurface(true); + + appWindow.mAttrs.flags |= FLAG_NOT_FOCUSABLE; + assertFalse(appWindow.canBeImeTarget()); + + DisplayContent secondDisplay = createNewDisplay(); + final WindowState embeddedWindow = createWindow(null, TYPE_APPLICATION, secondDisplay, + "embeddedWindow"); + appWindow.addEmbeddedDisplayContent(secondDisplay); + embeddedWindow.setHasSurface(true); + embeddedWindow.mAttrs.flags &= ~FLAG_NOT_FOCUSABLE; + assertTrue(appWindow.canBeImeTarget()); + } + + @Test public void testGetWindow() { final WindowState root = createWindow(null, TYPE_APPLICATION, "root"); final WindowState mediaChild = createWindow(root, TYPE_APPLICATION_MEDIA, "mediaChild"); |