summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/wm/TaskPositioner.java5
-rw-r--r--services/core/java/com/android/server/wm/TaskRecord.java20
2 files changed, 24 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/wm/TaskPositioner.java b/services/core/java/com/android/server/wm/TaskPositioner.java
index 7714458bb167..4cc31953a614 100644
--- a/services/core/java/com/android/server/wm/TaskPositioner.java
+++ b/services/core/java/com/android/server/wm/TaskPositioner.java
@@ -438,6 +438,11 @@ class TaskPositioner {
// This is a moving or scrolling operation.
mTask.mStack.getDimBounds(mTmpRect);
+ // If a target window is covered by system bar, there is no way to move it again by touch.
+ // So we exclude them from stack bounds. and then it will be shown inside stable area.
+ Rect stableBounds = new Rect();
+ mDisplayContent.getStableRect(stableBounds);
+ mTmpRect.intersect(stableBounds);
int nX = (int) x;
int nY = (int) y;
diff --git a/services/core/java/com/android/server/wm/TaskRecord.java b/services/core/java/com/android/server/wm/TaskRecord.java
index 15060e1fc712..a279ab57afb0 100644
--- a/services/core/java/com/android/server/wm/TaskRecord.java
+++ b/services/core/java/com/android/server/wm/TaskRecord.java
@@ -2244,9 +2244,27 @@ class TaskRecord extends ConfigurationContainer {
// by policy, make sure the window remains within parent somewhere
final float density =
((float) newParentConfig.densityDpi) / DisplayMetrics.DENSITY_DEFAULT;
- fitWithinBounds(outOverrideBounds, newParentConfig.windowConfiguration.getBounds(),
+ final Rect parentBounds =
+ new Rect(newParentConfig.windowConfiguration.getBounds());
+ final ActivityDisplay display = mStack.getDisplay();
+ if (display != null && display.mDisplayContent != null) {
+ // If a freeform window moves below system bar, there is no way to move it again
+ // by touch. Because its caption is covered by system bar. So we exclude them
+ // from stack bounds. and then caption will be shown inside stable area.
+ final Rect stableBounds = new Rect();
+ display.mDisplayContent.getStableRect(stableBounds);
+ parentBounds.intersect(stableBounds);
+ }
+
+ fitWithinBounds(outOverrideBounds, parentBounds,
(int) (density * WindowState.MINIMUM_VISIBLE_WIDTH_IN_DP),
(int) (density * WindowState.MINIMUM_VISIBLE_HEIGHT_IN_DP));
+
+ // Prevent to overlap caption with stable insets.
+ final int offsetTop = parentBounds.top - outOverrideBounds.top;
+ if (offsetTop > 0) {
+ outOverrideBounds.offset(0, offsetTop);
+ }
}
computeConfigResourceOverrides(getResolvedOverrideConfiguration(), newParentConfig);
}