From 387b97fa84ce6faef6553ccdbdba6d49dcfcc16f Mon Sep 17 00:00:00 2001 From: Maryam Dehaini Date: Wed, 5 Feb 2025 12:04:29 -0800 Subject: Allow long clicks on maximize icon using switch access The current implementation only allows listeners from a touchscreen source. When a user uses switch access to long click, the onLongClick listener is called, but the onTouch listener never is. This change ignores onLongClick calls that have gone through onTouch first but allows long clicks that are recieved directly from an onLongClick call. Bug: 391652399 Test: open and close maximize menu using both switch access and touchscreen Flag: com.android.window.flags.enable_desktop_windowing_mode Change-Id: Ie7d703a53aab8fa097b4850ca7d35129f1f58f77 --- .../shell/windowdecor/DesktopModeWindowDecorViewModel.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 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 a3a0baebcba1..235ebd7cf3cc 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 @@ -911,7 +911,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, private boolean mIsCustomHeaderGesture; private boolean mIsResizeGesture; private boolean mIsDragging; - private boolean mTouchscreenInUse; + private boolean mLongClickDisabled; private int mDragPointerId = -1; private MotionEvent mMotionEvent; @@ -997,10 +997,12 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, mMotionEvent = e; final int id = v.getId(); final DesktopModeWindowDecoration decoration = mWindowDecorByTaskId.get(mTaskId); - if ((e.getSource() & SOURCE_TOUCHSCREEN) == SOURCE_TOUCHSCREEN) { - mTouchscreenInUse = e.getActionMasked() != ACTION_UP - && e.getActionMasked() != ACTION_CANCEL; - } + final boolean touchscreenSource = + (e.getSource() & SOURCE_TOUCHSCREEN) == SOURCE_TOUCHSCREEN; + // Disable long click during events from a non-touchscreen source + mLongClickDisabled = !touchscreenSource && e.getActionMasked() != ACTION_UP + && e.getActionMasked() != ACTION_CANCEL; + if (id != R.id.caption_handle && id != R.id.desktop_mode_caption && id != R.id.open_menu_button && id != R.id.close_window && id != R.id.maximize_window && id != R.id.minimize_window) { @@ -1070,7 +1072,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel, @Override public boolean onLongClick(View v) { final int id = v.getId(); - if (id == R.id.maximize_window && mTouchscreenInUse) { + if (id == R.id.maximize_window && !mLongClickDisabled) { final DesktopModeWindowDecoration decoration = mWindowDecorByTaskId.get(mTaskId); moveTaskToFront(decoration.mTaskInfo); if (decoration.isMaximizeMenuActive()) { -- cgit v1.2.3-59-g8ed1b