Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7d1daa11 authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

Remove Pointer Tracking in WM: Disable TaskTapPointerEventListener

As part of the effort to remove input code from WM, add a flag to
disable TaskTapPointerEventListener in WM.

Its responsibilities are already handled by other means:
- Taps outside focused tasks are reported to WM directly by
  InputDispatcher using onPointerDownOutsideFocus().
- Freeform window resizing is handled by WM Shell in
  DragResizeInputListener.

Since its behavior is obsolete, remove it safely with a flag.

Bug: 315321016
Test: manual
Change-Id: Iaf9c9c2a4eade8b645cce1fa38734f15d3487593
parent fe7861ca
Loading
Loading
Loading
Loading
+22 −5
Original line number Diff line number Diff line
@@ -545,10 +545,12 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
    boolean isDefaultDisplay;

    /** Detect user tapping outside of current focused task bounds .*/
    // TODO(b/315321016): Remove once pointer event detection is removed from WM.
    @VisibleForTesting
    final TaskTapPointerEventListener mTapDetector;

    /** Detect user tapping outside of current focused root task bounds .*/
    // TODO(b/315321016): Remove once pointer event detection is removed from WM.
    private Region mTouchExcludeRegion = new Region();

    /** Save allocating when calculating rects */
@@ -1189,11 +1191,15 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                "PointerEventDispatcher" + mDisplayId, mDisplayId);
        mPointerEventDispatcher = new PointerEventDispatcher(inputChannel);

        if (com.android.input.flags.Flags.removePointerEventTrackingInWm()) {
            mTapDetector = null;
        } else {
            // Tap Listeners are supported for:
            // 1. All physical displays (multi-display).
            // 2. VirtualDisplays on VR, AA (and everything else).
            mTapDetector = new TaskTapPointerEventListener(mWmService, this);
            registerPointerEventListener(mTapDetector);
        }
        if (mWmService.mMousePositionTracker != null) {
            registerPointerEventListener(mWmService.mMousePositionTracker);
        }
@@ -3262,6 +3268,12 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
    }

    void updateTouchExcludeRegion() {
        if (mTapDetector == null) {
            // The touch exclude region is used to detect the region outside of the focused task
            // so that the tap detector can detect outside touches. Don't calculate the exclude
            // region when the tap detector is disabled.
            return;
        }
        final Task focusedTask = (mFocusedApp != null ? mFocusedApp.getTask() : null);
        if (focusedTask == null) {
            mTouchExcludeRegion.setEmpty();
@@ -3300,6 +3312,11 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
    }

    private void processTaskForTouchExcludeRegion(Task task, Task focusedTask, int delta) {
        if (mTapDetector == null) {
            // The touch exclude region is used to detect the region outside of the focused task
            // so that the tap detector can detect outside touches. Don't calculate the exclude
            // region when the tap detector is disabled.
        }
        final ActivityRecord topVisibleActivity = task.getTopVisibleActivity();

        if (topVisibleActivity == null || !topVisibleActivity.hasContentToDisplay()) {
+4 −0
Original line number Diff line number Diff line
@@ -45,6 +45,10 @@ public class TaskTapPointerEventListener implements PointerEventListener {

    public TaskTapPointerEventListener(WindowManagerService service,
            DisplayContent displayContent) {
        // TODO(b/315321016): Remove this class when the flag rollout is complete.
        if (com.android.input.flags.Flags.removePointerEventTrackingInWm()) {
            throw new IllegalStateException("TaskTapPointerEventListener should not be used!");
        }
        mService = service;
        mDisplayContent = displayContent;
    }