WindowManager: Emit windows from forAllWindows closer to Z-order
Otherwise IME windows will be reported as under the docked divider.
Bug: 77526241
Test: Manual. WindowContainerTraversalTests.
Change-Id: I008e253464b36c61973f49c7992352fb96649dc1
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 0de3c92..c710c97 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -3997,32 +3997,33 @@
return false;
}
+ private boolean applyImeWindowsIfNeeded(ToBooleanFunction<WindowState> callback,
+ boolean traverseTopToBottom) {
+ // If this window is the current IME target, so we need to process the IME windows
+ // directly above it. The exception is if we are in split screen
+ // in which case we process the IME at the DisplayContent level to
+ // ensure it is above the docked divider.
+ if (isInputMethodTarget() && !inSplitScreenWindowingMode()) {
+ if (getDisplayContent().forAllImeWindows(callback, traverseTopToBottom)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
private boolean applyInOrderWithImeWindows(ToBooleanFunction<WindowState> callback,
boolean traverseTopToBottom) {
if (traverseTopToBottom) {
- if (isInputMethodTarget()) {
- // This window is the current IME target, so we need to process the IME windows
- // directly above it.
- if (getDisplayContent().forAllImeWindows(callback, traverseTopToBottom)) {
- return true;
- }
- }
- if (callback.apply(this)) {
+ if (applyImeWindowsIfNeeded(callback, traverseTopToBottom)
+ || callback.apply(this)) {
return true;
}
} else {
- if (callback.apply(this)) {
+ if (callback.apply(this)
+ || applyImeWindowsIfNeeded(callback, traverseTopToBottom)) {
return true;
}
- if (isInputMethodTarget()) {
- // This window is the current IME target, so we need to process the IME windows
- // directly above it.
- if (getDisplayContent().forAllImeWindows(callback, traverseTopToBottom)) {
- return true;
- }
- }
}
-
return false;
}