Refine getTransformationMatrix for windows in a re-parented display
Currently, the translation of the transformation matrix computed by
WindowState.getTransformationMatrix is related to its own display.
However, if the display has been re-parented, the translation might
be misplaced to the visual result. This CL makes it return the global
transformation matrix.
Bug: 129098348
Test: atest WindowStateTests
Change-Id: I38da5b84a11890bf0f4a57eb9d5b7e71bdcc16a9
diff --git a/services/core/java/com/android/server/wm/AccessibilityController.java b/services/core/java/com/android/server/wm/AccessibilityController.java
index 6ce42ec..b6a5be8 100644
--- a/services/core/java/com/android/server/wm/AccessibilityController.java
+++ b/services/core/java/com/android/server/wm/AccessibilityController.java
@@ -1108,6 +1108,7 @@
// the window manager is still looking for where to put it.
// We will do the work when we get a focus change callback.
// TODO(b/112273690): Support multiple displays
+ // TODO(b/129098348): Support embedded displays
if (mService.getDefaultDisplayContentLocked().mCurrentFocus == null) {
return;
}
@@ -1400,7 +1401,28 @@
if (w.isVisibleLw()) {
outWindows.put(mTempLayer++, w);
}
- }, false /* traverseTopToBottom */ );
+ }, false /* traverseTopToBottom */);
+ mService.mRoot.forAllWindows(w -> {
+ final WindowState win = findRootDisplayParentWindow(w);
+ if (win != null && win.getDisplayContent().isDefaultDisplay && w.isVisibleLw()) {
+ // TODO(b/129098348): insert windows on child displays into outWindows based on
+ // root-display-parent window.
+ outWindows.put(mTempLayer++, w);
+ }
+ }, false /* traverseTopToBottom */);
+ }
+
+ private WindowState findRootDisplayParentWindow(WindowState win) {
+ WindowState displayParentWindow = win.getDisplayContent().getParentWindow();
+ if (displayParentWindow == null) {
+ return null;
+ }
+ WindowState candidate = displayParentWindow;
+ while (candidate != null) {
+ displayParentWindow = candidate;
+ candidate = displayParentWindow.getDisplayContent().getParentWindow();
+ }
+ return displayParentWindow;
}
private class MyHandler extends Handler {