Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeKeyGestureHandler.kt +9 −1 Original line number Diff line number Diff line Loading @@ -146,13 +146,21 @@ class DesktopModeKeyGestureHandler( KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_MAXIMIZE_FREEFORM_WINDOW -> { logV("Key gesture TOGGLE_MAXIMIZE_FREEFORM_WINDOW is handled") getGloballyFocusedDesktopTask()?.let { taskInfo -> val displayId = taskInfo.displayId val displayLayout = displayController.getDisplayLayout(displayId) if (displayLayout == null) { logW( "Display %d is not found, task displayId might be stale", displayId ) return } mainExecutor.execute { desktopTasksController .get() .toggleDesktopTaskSize( taskInfo, ToggleTaskSizeInteraction( isMaximized = isTaskMaximized(taskInfo, displayController), isMaximized = isTaskMaximized(taskInfo, displayLayout), source = ToggleTaskSizeInteraction.Source.KEYBOARD_SHORTCUT, inputMethod = DesktopModeEventLogger.Companion.InputMethod.KEYBOARD, Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt +1 −9 Original line number Diff line number Diff line Loading @@ -298,17 +298,9 @@ fun calculateAspectRatio(taskInfo: TaskInfo): Float { } /** Returns whether the task is maximized. */ fun isTaskMaximized(taskInfo: RunningTaskInfo, displayController: DisplayController): Boolean { val displayLayout = displayController.getDisplayLayout(taskInfo.displayId) ?: error("Could not get display layout for display=${taskInfo.displayId}") fun isTaskMaximized(taskInfo: RunningTaskInfo, displayLayout: DisplayLayout): Boolean { val stableBounds = Rect() displayLayout.getStableBounds(stableBounds) return isTaskMaximized(taskInfo, stableBounds) } /** Returns whether the task is maximized. */ fun isTaskMaximized(taskInfo: RunningTaskInfo, stableBounds: Rect): Boolean { val currentTaskBounds = taskInfo.configuration.windowConfiguration.bounds return if (taskInfo.isResizeable) { isTaskBoundsEqual(currentTaskBounds, stableBounds) Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +7 −1 Original line number Diff line number Diff line Loading @@ -2695,7 +2695,13 @@ class DesktopTasksController( currentDragBounds: Rect, motionEvent: MotionEvent, ) { if (isTaskMaximized(taskInfo, displayController)) { val displayId = taskInfo.displayId val displayLayout = displayController.getDisplayLayout(displayId) if (displayLayout == null) { logW("Display %d is not found, task displayId might be stale", displayId) return } if (isTaskMaximized(taskInfo, displayLayout)) { // Handle the case where we attempt to drag-to-maximize when already maximized: the task // position won't need to change but we want to animate the surface going back to the // maximized position. Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java +1 −3 Original line number Diff line number Diff line Loading @@ -807,9 +807,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, if (displayLayout == null) { return null; } final Rect stableBounds = new Rect(); displayLayout.getStableBounds(stableBounds); boolean isMaximized = DesktopModeUtils.isTaskMaximized(taskInfo, stableBounds); boolean isMaximized = DesktopModeUtils.isTaskMaximized(taskInfo, displayLayout); return new ToggleTaskSizeInteraction( isMaximized Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java +16 −6 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import static android.window.DesktopModeFlags.ENABLE_CAPTION_COMPAT_INSET_FORCE_ import static android.window.DesktopModeFlags.ENABLE_CAPTION_COMPAT_INSET_FORCE_CONSUMPTION_ALWAYS; import static com.android.internal.policy.SystemBarUtils.getDesktopViewAppHeaderHeightId; import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE; import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT; import static com.android.wm.shell.windowdecor.DragPositioningCallbackUtility.DragEventListener; import static com.android.wm.shell.windowdecor.DragResizeWindowGeometry.DisabledEdge; Loading Loading @@ -60,7 +61,6 @@ import android.os.Handler; import android.os.Trace; import android.os.UserHandle; import android.util.Size; import android.util.Slog; import android.view.Choreographer; import android.view.Display; import android.view.InsetsState; Loading @@ -80,6 +80,7 @@ import android.window.WindowContainerTransaction; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.policy.DesktopModeCompatPolicy; import com.android.internal.policy.SystemBarUtils; import com.android.internal.protolog.ProtoLog; import com.android.window.flags.Flags; import com.android.wm.shell.R; import com.android.wm.shell.RootTaskDisplayAreaOrganizer; Loading Loading @@ -936,14 +937,16 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin /** Update the view holder for app header. */ private void updateAppHeaderViewHolder(boolean inFullImmersive, boolean hasGlobalFocus) { if (!isAppHeader(mWindowDecorViewHolder)) return; if (mDisplayController.getDisplayLayout(mTaskInfo.displayId) == null) { Slog.w(TAG, "Display" + mTaskInfo.displayId + " is not found, task displayId might be stale"); final int displayId = mTaskInfo.displayId; final DisplayLayout displayLayout = mDisplayController.getDisplayLayout(displayId); if (displayLayout == null) { ProtoLog.w(WM_SHELL_DESKTOP_MODE, "%s: Display %d is not found, task displayId might be stale", TAG, displayId); return; } asAppHeader(mWindowDecorViewHolder).bindData(new AppHeaderViewHolder.HeaderData( mTaskInfo, DesktopModeUtils.isTaskMaximized(mTaskInfo, mDisplayController), DesktopModeUtils.isTaskMaximized(mTaskInfo, displayLayout), inFullImmersive, hasGlobalFocus, /* maximizeHoverEnabled= */ canOpenMaximizeMenu( Loading Loading @@ -1981,12 +1984,19 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin void setAnimatingTaskResizeOrReposition(boolean animatingTaskResizeOrReposition) { if (!isAppHeader(mWindowDecorViewHolder)) return; final int displayId = mTaskInfo.displayId; final DisplayLayout displayLayout = mDisplayController.getDisplayLayout(displayId); if (displayLayout == null) { ProtoLog.w(WM_SHELL_DESKTOP_MODE, "%s: Display %d is not found, task displayId might be stale", TAG, displayId); return; } final boolean inFullImmersive = mDesktopUserRepositories.getProfile(mTaskInfo.userId) .isTaskInFullImmersiveState(mTaskInfo.taskId); asAppHeader(mWindowDecorViewHolder).bindData(new AppHeaderViewHolder.HeaderData( mTaskInfo, DesktopModeUtils.isTaskMaximized(mTaskInfo, mDisplayController), DesktopModeUtils.isTaskMaximized(mTaskInfo, displayLayout), inFullImmersive, isFocused(), /* maximizeHoverEnabled= */ canOpenMaximizeMenu(animatingTaskResizeOrReposition), Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeKeyGestureHandler.kt +9 −1 Original line number Diff line number Diff line Loading @@ -146,13 +146,21 @@ class DesktopModeKeyGestureHandler( KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_MAXIMIZE_FREEFORM_WINDOW -> { logV("Key gesture TOGGLE_MAXIMIZE_FREEFORM_WINDOW is handled") getGloballyFocusedDesktopTask()?.let { taskInfo -> val displayId = taskInfo.displayId val displayLayout = displayController.getDisplayLayout(displayId) if (displayLayout == null) { logW( "Display %d is not found, task displayId might be stale", displayId ) return } mainExecutor.execute { desktopTasksController .get() .toggleDesktopTaskSize( taskInfo, ToggleTaskSizeInteraction( isMaximized = isTaskMaximized(taskInfo, displayController), isMaximized = isTaskMaximized(taskInfo, displayLayout), source = ToggleTaskSizeInteraction.Source.KEYBOARD_SHORTCUT, inputMethod = DesktopModeEventLogger.Companion.InputMethod.KEYBOARD, Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt +1 −9 Original line number Diff line number Diff line Loading @@ -298,17 +298,9 @@ fun calculateAspectRatio(taskInfo: TaskInfo): Float { } /** Returns whether the task is maximized. */ fun isTaskMaximized(taskInfo: RunningTaskInfo, displayController: DisplayController): Boolean { val displayLayout = displayController.getDisplayLayout(taskInfo.displayId) ?: error("Could not get display layout for display=${taskInfo.displayId}") fun isTaskMaximized(taskInfo: RunningTaskInfo, displayLayout: DisplayLayout): Boolean { val stableBounds = Rect() displayLayout.getStableBounds(stableBounds) return isTaskMaximized(taskInfo, stableBounds) } /** Returns whether the task is maximized. */ fun isTaskMaximized(taskInfo: RunningTaskInfo, stableBounds: Rect): Boolean { val currentTaskBounds = taskInfo.configuration.windowConfiguration.bounds return if (taskInfo.isResizeable) { isTaskBoundsEqual(currentTaskBounds, stableBounds) Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +7 −1 Original line number Diff line number Diff line Loading @@ -2695,7 +2695,13 @@ class DesktopTasksController( currentDragBounds: Rect, motionEvent: MotionEvent, ) { if (isTaskMaximized(taskInfo, displayController)) { val displayId = taskInfo.displayId val displayLayout = displayController.getDisplayLayout(displayId) if (displayLayout == null) { logW("Display %d is not found, task displayId might be stale", displayId) return } if (isTaskMaximized(taskInfo, displayLayout)) { // Handle the case where we attempt to drag-to-maximize when already maximized: the task // position won't need to change but we want to animate the surface going back to the // maximized position. Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java +1 −3 Original line number Diff line number Diff line Loading @@ -807,9 +807,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, if (displayLayout == null) { return null; } final Rect stableBounds = new Rect(); displayLayout.getStableBounds(stableBounds); boolean isMaximized = DesktopModeUtils.isTaskMaximized(taskInfo, stableBounds); boolean isMaximized = DesktopModeUtils.isTaskMaximized(taskInfo, displayLayout); return new ToggleTaskSizeInteraction( isMaximized Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java +16 −6 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import static android.window.DesktopModeFlags.ENABLE_CAPTION_COMPAT_INSET_FORCE_ import static android.window.DesktopModeFlags.ENABLE_CAPTION_COMPAT_INSET_FORCE_CONSUMPTION_ALWAYS; import static com.android.internal.policy.SystemBarUtils.getDesktopViewAppHeaderHeightId; import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE; import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT; import static com.android.wm.shell.windowdecor.DragPositioningCallbackUtility.DragEventListener; import static com.android.wm.shell.windowdecor.DragResizeWindowGeometry.DisabledEdge; Loading Loading @@ -60,7 +61,6 @@ import android.os.Handler; import android.os.Trace; import android.os.UserHandle; import android.util.Size; import android.util.Slog; import android.view.Choreographer; import android.view.Display; import android.view.InsetsState; Loading @@ -80,6 +80,7 @@ import android.window.WindowContainerTransaction; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.policy.DesktopModeCompatPolicy; import com.android.internal.policy.SystemBarUtils; import com.android.internal.protolog.ProtoLog; import com.android.window.flags.Flags; import com.android.wm.shell.R; import com.android.wm.shell.RootTaskDisplayAreaOrganizer; Loading Loading @@ -936,14 +937,16 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin /** Update the view holder for app header. */ private void updateAppHeaderViewHolder(boolean inFullImmersive, boolean hasGlobalFocus) { if (!isAppHeader(mWindowDecorViewHolder)) return; if (mDisplayController.getDisplayLayout(mTaskInfo.displayId) == null) { Slog.w(TAG, "Display" + mTaskInfo.displayId + " is not found, task displayId might be stale"); final int displayId = mTaskInfo.displayId; final DisplayLayout displayLayout = mDisplayController.getDisplayLayout(displayId); if (displayLayout == null) { ProtoLog.w(WM_SHELL_DESKTOP_MODE, "%s: Display %d is not found, task displayId might be stale", TAG, displayId); return; } asAppHeader(mWindowDecorViewHolder).bindData(new AppHeaderViewHolder.HeaderData( mTaskInfo, DesktopModeUtils.isTaskMaximized(mTaskInfo, mDisplayController), DesktopModeUtils.isTaskMaximized(mTaskInfo, displayLayout), inFullImmersive, hasGlobalFocus, /* maximizeHoverEnabled= */ canOpenMaximizeMenu( Loading Loading @@ -1981,12 +1984,19 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin void setAnimatingTaskResizeOrReposition(boolean animatingTaskResizeOrReposition) { if (!isAppHeader(mWindowDecorViewHolder)) return; final int displayId = mTaskInfo.displayId; final DisplayLayout displayLayout = mDisplayController.getDisplayLayout(displayId); if (displayLayout == null) { ProtoLog.w(WM_SHELL_DESKTOP_MODE, "%s: Display %d is not found, task displayId might be stale", TAG, displayId); return; } final boolean inFullImmersive = mDesktopUserRepositories.getProfile(mTaskInfo.userId) .isTaskInFullImmersiveState(mTaskInfo.taskId); asAppHeader(mWindowDecorViewHolder).bindData(new AppHeaderViewHolder.HeaderData( mTaskInfo, DesktopModeUtils.isTaskMaximized(mTaskInfo, mDisplayController), DesktopModeUtils.isTaskMaximized(mTaskInfo, displayLayout), inFullImmersive, isFocused(), /* maximizeHoverEnabled= */ canOpenMaximizeMenu(animatingTaskResizeOrReposition), Loading