From 159f9de407c1f79384312b51d038d71f5610b6b8 Mon Sep 17 00:00:00 2001 From: Gustav Sennton Date: Mon, 27 Nov 2023 16:13:12 +0000 Subject: Desktop Windowing: add sysprop flags for shadows and rounded corners We add three flags: 1. Enable/disable rounded corners (boolean flag) 2. Enable/disable window shadows (boolean flag) 3. Enable/disable window shadows for the focused window (boolean flag) - this flag only applies if flag 2 is disabled. This CL does NOT update default bevahiours, i.e. in desktop mode, window shadows and rounded corners are still shown by default. adb commands: https://paste.googleplex.com/6310119139180544 Screenshot with rounded corners: https://screenshot.googleplex.com/BHw6hDPnSa8a8yN.png Screenshot without rounded corners: https://screenshot.googleplex.com/98VVVd3Jk8y8dnF.png Note: the screenshots don't seem to capture window shadows. Bug: 316867234, 316865378 Test: unit tests for default behavior, ran adb commands to check sysprop flags behavior Change-Id: Iaafb50ebf82270c8e38bd957176d83ce6182a6dd --- .../wm/shell/desktopmode/DesktopModeStatus.java | 37 ++++++++++ .../wm/shell/desktopmode/DesktopTasksController.kt | 3 + .../windowdecor/DesktopModeWindowDecoration.java | 83 +++++++++++++--------- .../DesktopModeWindowDecorationTests.java | 77 ++++++++++++++++++++ 4 files changed, 167 insertions(+), 33 deletions(-) (limited to 'libs') diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeStatus.java b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeStatus.java index dc82fc1b35dd..88949b2a5acd 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeStatus.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeStatus.java @@ -54,6 +54,26 @@ public class DesktopModeStatus { private static final boolean IS_STASHING_ENABLED = SystemProperties.getBoolean( "persist.wm.debug.desktop_stashing", false); + /** + * Flag to indicate whether to apply shadows to windows in desktop mode. + */ + private static final boolean USE_WINDOW_SHADOWS = SystemProperties.getBoolean( + "persist.wm.debug.desktop_use_window_shadows", true); + + /** + * Flag to indicate whether to apply shadows to the focused window in desktop mode. + * + * Note: this flag is only relevant if USE_WINDOW_SHADOWS is false. + */ + private static final boolean USE_WINDOW_SHADOWS_FOCUSED_WINDOW = SystemProperties.getBoolean( + "persist.wm.debug.desktop_use_window_shadows_focused_window", false); + + /** + * Flag to indicate whether to apply shadows to windows in desktop mode. + */ + private static final boolean USE_ROUNDED_CORNERS = SystemProperties.getBoolean( + "persist.wm.debug.desktop_use_rounded_corners", true); + /** * Return {@code true} is desktop windowing proto 2 is enabled */ @@ -81,4 +101,21 @@ public class DesktopModeStatus { public static boolean isStashingEnabled() { return IS_STASHING_ENABLED; } + + /** + * Return whether to use window shadows. + * + * @param isFocusedWindow whether the window to apply shadows to is focused + */ + public static boolean useWindowShadow(boolean isFocusedWindow) { + return USE_WINDOW_SHADOWS + || (USE_WINDOW_SHADOWS_FOCUSED_WINDOW && isFocusedWindow); + } + + /** + * Return whether to use rounded corners for windows. + */ + public static boolean useRoundedCorners() { + return USE_ROUNDED_CORNERS; + } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt index 144555dd70c3..4a1bcaa7168a 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt @@ -721,6 +721,9 @@ class DesktopTasksController( finishTransaction: SurfaceControl.Transaction ) { // Add rounded corners to freeform windows + if (!DesktopModeStatus.useRoundedCorners()) { + return + } val cornerRadius = ScreenDecorationsUtils.getWindowCornerRadius(context) info.changes .filter { it.taskInfo?.windowingMode == WINDOWING_MODE_FREEFORM } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java index 6ec91e0e28dd..7a9afc899327 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java @@ -46,6 +46,7 @@ import android.view.ViewConfiguration; import android.widget.ImageButton; import android.window.WindowContainerTransaction; +import com.android.internal.annotations.VisibleForTesting; import com.android.internal.policy.ScreenDecorationsUtils; import com.android.launcher3.icons.BaseIconFactory; import com.android.launcher3.icons.IconProvider; @@ -195,46 +196,16 @@ public class DesktopModeWindowDecoration extends WindowDecoration