From d14589e05184f6be44b0dd46e957a6ad5f11e280 Mon Sep 17 00:00:00 2001 From: Ben Lin Date: Thu, 30 Apr 2020 16:17:41 -0700 Subject: [PATCH] Enforce max size for resizing operations. Previously, maxVisibleSize is only enforced when we want to preserve orientation. However, we should enforce it when in complete freeform also. Even for preserve orientation case, since it calculates two possible rectangles and grab the bigger one if it's a grow operation, it's possible the bigger rectangle is beyond the max possible size. By setting the limitations early, this will no longer happen. Bug: 154936459 Bug: 155433395 Test: Drag-resize a window that has a max size set (PIP window), and now it is properly constrained. Test: atest TaskPositionerTests Change-Id: I3e9bc615554561e035a5c7110d0400687c6ba365 --- .../android/internal/policy/TaskResizingAlgorithm.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/java/com/android/internal/policy/TaskResizingAlgorithm.java b/core/java/com/android/internal/policy/TaskResizingAlgorithm.java index 1fce098fb93eb..1ec020696cf35 100644 --- a/core/java/com/android/internal/policy/TaskResizingAlgorithm.java +++ b/core/java/com/android/internal/policy/TaskResizingAlgorithm.java @@ -91,14 +91,14 @@ public class TaskResizingAlgorithm { int width = right - left; int height = bottom - top; if ((ctrlType & CTRL_LEFT) != 0) { - width = Math.max(minVisibleWidth, width - deltaX); + width = Math.max(minVisibleWidth, Math.min(width - deltaX, maxVisibleSize.x)); } else if ((ctrlType & CTRL_RIGHT) != 0) { - width = Math.max(minVisibleWidth, width + deltaX); + width = Math.max(minVisibleWidth, Math.min(width + deltaX, maxVisibleSize.x)); } if ((ctrlType & CTRL_TOP) != 0) { - height = Math.max(minVisibleHeight, height - deltaY); + height = Math.max(minVisibleHeight, Math.min(height - deltaY, maxVisibleSize.y)); } else if ((ctrlType & CTRL_BOTTOM) != 0) { - height = Math.max(minVisibleHeight, height + deltaY); + height = Math.max(minVisibleHeight, Math.min(height + deltaY, maxVisibleSize.y)); } // If we have to preserve the orientation - check that we are doing so.