diff options
author | 2024-07-22 20:57:47 +0000 | |
---|---|---|
committer | 2024-07-22 20:57:47 +0000 | |
commit | 10f56c673634650f8dd00101e533e353f5ee6e3b (patch) | |
tree | 6218a8fed2c4a6d076d7f4b2b59b4e2b95c91cf6 | |
parent | 7fe4dd3f291bf8e0f1c15feca0387805decf8112 (diff) | |
parent | d5f04ff30b83fc10fa7c115aeea9725b84ceaafc (diff) |
Merge "Forward click and hover inputs to caption handle." into main
3 files changed, 22 insertions, 21 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 0e8fd7c7d0a1..de1948331f40 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 @@ -669,12 +669,6 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { View v, MotionEvent e) { final int id = v.getId(); if (id == R.id.caption_handle) { - if (e.getActionMasked() == MotionEvent.ACTION_DOWN) { - // Caption handle is located within the status bar region, meaning the - // DisplayPolicy will attempt to transfer this input to status bar if it's - // a swipe down. Pilfer here to keep the gesture in handle alone. - mInputManager.pilferPointers(v.getViewRootImpl().getInputToken()); - } handleCaptionThroughStatusBar(e, decoration); final boolean wasDragging = mIsDragging; updateDragStatus(e.getActionMasked()); 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 529def7ca3d7..6e883251ddde 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 @@ -520,11 +520,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin return new AppHandleViewHolder( mResult.mRootView, mOnCaptionTouchListener, - mOnCaptionButtonClickListener, - (v, event) -> { - updateHoverAndPressStatus(event); - return true; - } + mOnCaptionButtonClickListener ); } else if (mRelayoutParams.mLayoutResId == R.layout.desktop_mode_app_header) { @@ -589,9 +585,11 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin controlsElement.mWidthResId = R.dimen.desktop_mode_customizable_caption_margin_end; controlsElement.mAlignment = RelayoutParams.OccludingCaptionElement.Alignment.END; relayoutParams.mOccludingCaptionElements.add(controlsElement); - } else if (isAppHandle) { + } else if (isAppHandle && !Flags.enableAdditionalWindowsAboveStatusBar()) { // The focused decor (fullscreen/split) does not need to handle input because input in // the App Handle is handled by the InputMonitor in DesktopModeWindowDecorViewModel. + // Note: This does not apply with the above flag enabled as the status bar input layer + // will forward events to the handle directly. relayoutParams.mInputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL; } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/AppHandleViewHolder.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/AppHandleViewHolder.kt index 76dfe37c7cc0..57d8cac2d336 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/AppHandleViewHolder.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/AppHandleViewHolder.kt @@ -21,10 +21,11 @@ import android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM import android.content.res.ColorStateList import android.graphics.Color import android.graphics.Point +import android.hardware.input.InputManager +import android.view.MotionEvent.ACTION_DOWN import android.view.SurfaceControl import android.view.View import android.view.View.OnClickListener -import android.view.View.OnHoverListener import android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS import android.view.WindowManager import android.widget.ImageButton @@ -39,9 +40,8 @@ import com.android.wm.shell.windowdecor.additionalviewcontainer.AdditionalSystem */ internal class AppHandleViewHolder( rootView: View, - private val onCaptionTouchListener: View.OnTouchListener, - private val onCaptionButtonClickListener: OnClickListener, - private val onCaptionHoverListener: OnHoverListener, + onCaptionTouchListener: View.OnTouchListener, + onCaptionButtonClickListener: OnClickListener ) : WindowDecorationViewHolder(rootView) { companion object { @@ -51,6 +51,7 @@ internal class AppHandleViewHolder( private val windowManager = context.getSystemService(WindowManager::class.java) private val captionView: View = rootView.requireViewById(R.id.desktop_mode_caption) private val captionHandle: ImageButton = rootView.requireViewById(R.id.caption_handle) + private val inputManager = context.getSystemService(InputManager::class.java) // An invisible View that takes up the same coordinates as captionHandle but is layered // above the status bar. The purpose of this View is to receive input intended for @@ -61,7 +62,6 @@ internal class AppHandleViewHolder( captionView.setOnTouchListener(onCaptionTouchListener) captionHandle.setOnTouchListener(onCaptionTouchListener) captionHandle.setOnClickListener(onCaptionButtonClickListener) - captionHandle.setOnHoverListener(onCaptionHoverListener) } override fun bindData( @@ -106,10 +106,19 @@ internal class AppHandleViewHolder( // gesture listener that receives events before window. This is to prevent notification // shade gesture when we swipe down to enter desktop. lp.inputFeatures = WindowManager.LayoutParams.INPUT_FEATURE_SPY - view.id = R.id.caption_handle - view.setOnClickListener(onCaptionButtonClickListener) - view.setOnTouchListener(onCaptionTouchListener) - view.setOnHoverListener(onCaptionHoverListener) + view.setOnHoverListener { _, event -> + captionHandle.onHoverEvent(event) + } + // Caption handle is located within the status bar region, meaning the + // DisplayPolicy will attempt to transfer this input to status bar if it's + // a swipe down. Pilfer here to keep the gesture in handle alone. + view.setOnTouchListener { v, event -> + if (event.actionMasked == ACTION_DOWN) { + inputManager.pilferPointers(v.viewRootImpl.inputToken) + } + captionHandle.dispatchTouchEvent(event) + true + } windowManager.updateViewLayout(view, lp) } |