Forward click and hover inputs to caption handle.
Simplifies input handling for statusBarInputLayer by having click/hover
listener call the equivalent event on captionHandle view directly. This
fixes an issue with hover events not being passed correctly.
This CL also fixes press events by adding that handling to
statusBarInputLayer's onTouchListener.
Bug: 341997116
Test: manual
Flag: com.android.window.flags.enable_additional_windows_above_status_bar
Change-Id: I83fd7d2c607781b69c7742cfd9aae6d1f58c4fe7
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 8312aef..d1ec1c8 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 @@
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 529def7..6e88325 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 @@
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 @@
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 76dfe37..57d8cac 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.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 @@
*/
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 @@
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 @@
captionView.setOnTouchListener(onCaptionTouchListener)
captionHandle.setOnTouchListener(onCaptionTouchListener)
captionHandle.setOnClickListener(onCaptionButtonClickListener)
- captionHandle.setOnHoverListener(onCaptionHoverListener)
}
override fun bindData(
@@ -106,10 +106,19 @@
// 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)
}