diff options
| author | 2023-04-05 18:12:00 -0700 | |
|---|---|---|
| committer | 2023-04-06 18:22:49 +0000 | |
| commit | 18c329c2080ec6b40d632d1fcdbee3fc424059cf (patch) | |
| tree | d29945ae1eb3b4ca9d97e9a85290b1dda5969f5b | |
| parent | bbbe3c7935faf877303e2a9c9a7940b30cb34c54 (diff) | |
Prevent multiple handle menus from opening.
Changes the handle menu logic such that if the open menu button is
clicked while the menu is currently open, it will close the existing
menu rather than make a second handle menu.
Bug: 277125646
Test: Manual; click the exposed corners of the open menu button while
handle menu is open. Confirm clicking handle menu pills is unaffected.
Change-Id: I230e1dcac2a338c41a7c74acb37e3c13b711f218
2 files changed, 16 insertions, 3 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java index f99821747fef..181a5beeb487 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java @@ -312,8 +312,12 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { } else if (id == R.id.back_button) { mTaskOperations.injectBackKey(); } else if (id == R.id.caption_handle || id == R.id.open_menu_button) { - moveTaskToFront(mTaskOrganizer.getRunningTaskInfo(mTaskId)); - decoration.createHandleMenu(); + if (!decoration.isHandleMenuActive()) { + moveTaskToFront(mTaskOrganizer.getRunningTaskInfo(mTaskId)); + decoration.createHandleMenu(); + } else { + decoration.closeHandleMenu(); + } } else if (id == R.id.desktop_button) { mDesktopModeController.ifPresent(c -> c.setDesktopModeActive(true)); mDesktopTasksController.ifPresent(c -> c.moveToDesktop(mTaskId)); 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 e08d40d76c16..23d3c6a3a151 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 @@ -446,6 +446,14 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin if (mHandleMenuAppInfoPill.mWindowViewHost.getView().getWidth() == 0) return; PointF inputPoint = offsetCaptionLocation(ev); + + // If this is called before open_menu_button's onClick, we don't want to close + // the menu since it will just reopen in onClick. + final boolean pointInOpenMenuButton = pointInView( + mResult.mRootView.findViewById(R.id.open_menu_button), + inputPoint.x, + inputPoint.y); + final boolean pointInAppInfoPill = pointInView( mHandleMenuAppInfoPill.mWindowViewHost.getView(), inputPoint.x - mHandleMenuAppInfoPillPosition.x - mResult.mDecorContainerOffsetX, @@ -465,7 +473,8 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin - mResult.mDecorContainerOffsetX, inputPoint.y - mHandleMenuMoreActionsPillPosition.y - mResult.mDecorContainerOffsetY); - if (!pointInAppInfoPill && !pointInWindowingPill && !pointInMoreActionsPill) { + if (!pointInAppInfoPill && !pointInWindowingPill + && !pointInMoreActionsPill && !pointInOpenMenuButton) { closeHandleMenu(); } } |