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

Commit fe7861ca authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

Pointer Icon Refactor: Disable mouse position tracking in WM

The mouse position is tracked in WM so that it can provide the position
of the cursor when an app wants to update the pointer icon at will, and
when WM wants to restore the icon after the pointer leaves a window.

The refactored pointer icon pipeline provides a resolution to both these
cases, so WM will no longer need to track mouse position.

Bug: 293587049
Test: manual
Change-Id: I895e2ec4ef13cb221981ce653f977a5ed154cc9b
parent abb8f6cc
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1194,7 +1194,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        // 2. VirtualDisplays on VR, AA (and everything else).
        mTapDetector = new TaskTapPointerEventListener(mWmService, this);
        registerPointerEventListener(mTapDetector);
        if (mWmService.mMousePositionTracker != null) {
            registerPointerEventListener(mWmService.mMousePositionTracker);
        }
        if (mWmService.mAtmService.getRecentTasks() != null) {
            registerPointerEventListener(
                    mWmService.mAtmService.getRecentTasks().getInputListener());
+15 −1
Original line number Diff line number Diff line
@@ -7302,7 +7302,12 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    MousePositionTracker mMousePositionTracker = new MousePositionTracker();
    // The mouse position tracker will be obsolete after the Pointer Icon Refactor.
    // TODO(b/293587049): Remove after the refactoring is fully rolled out.
    @Nullable
    final MousePositionTracker mMousePositionTracker =
            com.android.input.flags.Flags.enablePointerChoreographer() ? null
                    : new MousePositionTracker();

    private static class MousePositionTracker implements PointerEventListener {
        private boolean mLatestEventWasMouse;
@@ -7354,6 +7359,9 @@ public class WindowManagerService extends IWindowManager.Stub
    };

    void updatePointerIcon(IWindow client) {
        if (mMousePositionTracker == null) {
            return;
        }
        int pointerDisplayId;
        float mouseX, mouseY;

@@ -7400,6 +7408,9 @@ public class WindowManagerService extends IWindowManager.Stub
    }

    void restorePointerIconLocked(DisplayContent displayContent, float latestX, float latestY) {
        if (mMousePositionTracker == null) {
            return;
        }
        // Mouse position tracker has not been getting updates while dragging, update it now.
        if (!mMousePositionTracker.updatePosition(
                displayContent.getDisplayId(), latestX, latestY)) {
@@ -7423,6 +7434,9 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }
    void setMousePointerDisplayId(int displayId) {
        if (mMousePositionTracker == null) {
            return;
        }
        mMousePositionTracker.setPointerDisplayId(displayId);
    }