diff options
| author | 2019-04-24 14:20:15 -0700 | |
|---|---|---|
| committer | 2019-04-25 16:41:05 -0700 | |
| commit | 84b30d2c54c4eb2af66ed17714c7eadf253df7ce (patch) | |
| tree | 7e529237f1b779dcba4146d9623596b280bf087c | |
| parent | 6805b6ae0d574f44fd7985e76bd6b9556f390312 (diff) | |
[wm] Adjust freeform header not to be overlapped with stable insets
freeform bounds should not be overlapped with statusBar and navigationBar.
If it is overlapped, we can't control freeform anymore. So we adjusted
freeform bounds not to be overlapped on launching and moving task.
Test: move freeform to navigationBar & launching below navigationBar
Test: atest WmTests:TaskRecordTests WmTests:TaskPositionerTests
Bug: 129521219
Change-Id: I353ba930269ec753c97d719819364436bda280cb
(cherry picked from commit 55fbe465f2b40e0f1886691488825a243a3acf79)
| -rw-r--r-- | services/core/java/com/android/server/wm/TaskPositioner.java | 5 | ||||
| -rw-r--r-- | services/core/java/com/android/server/wm/TaskRecord.java | 20 |
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); } |