summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Robert Horvath <robhor@google.com> 2022-03-25 18:07:44 +0100
committer Robert Horvath <robhor@google.com> 2022-03-25 18:07:44 +0100
commit06bab93a1ab636f15b2911e6b8aac4166da2bf6c (patch)
tree5620e04b48881f9d4cab20b10d21c139960040af
parent7e5c2bd6082dc1816edea01470ecea4ce78ef371 (diff)
Change PiP stash scoring to distance moved
When there are multiple possible stashing positions for a PiP, before we chose the one that displaces the PiP by the least area (dx * height + dy * width). With eg. very tall expanded PiPs, this can lead a large dy to be preferred over a small dx because of the big height multiplier, causing the PiP to move a 'greater distance'. This change makes the stashing position with the least `dx + dy` preferred. Bug: 226579596 Test: manual Change-Id: I29f74a2bec670c3a3219c6d50bf1102a41d42b6b
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipKeepClearAlgorithm.kt2
1 files changed, 1 insertions, 1 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipKeepClearAlgorithm.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipKeepClearAlgorithm.kt
index e7eb8364466f..8fe584d292b7 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipKeepClearAlgorithm.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/TvPipKeepClearAlgorithm.kt
@@ -399,7 +399,7 @@ class TvPipKeepClearAlgorithm(private val clock: () -> Long) {
return stashCandidates.minByOrNull {
val dx = abs(it.left - bounds.left)
val dy = abs(it.top - bounds.top)
- dx * bounds.height() + dy * bounds.width()
+ return@minByOrNull dx + dy
}!!
}