From 37bff76c4a1feb54384c4f976b22a7298f941ab7 Mon Sep 17 00:00:00 2001 From: Yunfan Chen Date: Tue, 23 May 2023 17:30:53 +0900 Subject: [PATCH] Provide mandatory gesture insets from the shell caption This change let the shell caption provide the mandatory gesture insets. However, note that, due to the lack of relavant insets support for the shell insets yet, the insets may be unstable during drag-resizing or drag-moving. Though as the caption insets is there, it should not be a big issue, and for long term we can get rid of the hack to let the insets be stable during drag events. This change doesn't contain the hack for mandatory gesture insets. Bug: 197277883 Test: WindowInsetsPolicyTest with CAPTION_ON_SHELL enabled Change-Id: Ifb482311162ef167b4e2d8a375974b7696f9d28c --- .../com/android/wm/shell/windowdecor/WindowDecoration.java | 5 +++++ .../android/wm/shell/windowdecor/WindowDecorationTests.java | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java index ac5ff20759016..67ec6cf4304ec 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java @@ -248,6 +248,9 @@ public abstract class WindowDecoration mCaptionInsetsRect.bottom = mCaptionInsetsRect.top + captionHeight + params.mCaptionY; wct.addInsetsSource(mTaskInfo.token, mOwner, 0 /* index */, WindowInsets.Type.captionBar(), mCaptionInsetsRect); + wct.addInsetsSource(mTaskInfo.token, + mOwner, 0 /* index */, WindowInsets.Type.mandatorySystemGestures(), + mCaptionInsetsRect); } else { startT.hide(mCaptionContainerSurface); } @@ -345,6 +348,8 @@ public abstract class WindowDecoration final WindowContainerTransaction wct = mWindowContainerTransactionSupplier.get(); wct.removeInsetsSource(mTaskInfo.token, mOwner, 0 /* index */, WindowInsets.Type.captionBar()); + wct.removeInsetsSource(mTaskInfo.token, + mOwner, 0 /* index */, WindowInsets.Type.mandatorySystemGestures()); mTaskOrganizer.applyTransaction(wct); } diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/WindowDecorationTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/WindowDecorationTests.java index 5a2326b9c3936..f941e9501a3fe 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/WindowDecorationTests.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/WindowDecorationTests.java @@ -316,7 +316,8 @@ public class WindowDecorationTests extends ShellTestCase { releaseOrder.verify(t).remove(captionContainerSurface); releaseOrder.verify(t).remove(decorContainerSurface); releaseOrder.verify(t).apply(); - verify(mMockWindowContainerTransaction) + // Expect to remove two insets sources, the caption insets and the mandatory gesture insets. + verify(mMockWindowContainerTransaction, Mockito.times(2)) .removeInsetsSource(eq(taskInfo.token), any(), anyInt(), anyInt()); }