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

Commit 8b1399e1 authored by Byoungho Jung's avatar Byoungho Jung Committed by Prabir Pradhan
Browse files

Set pointer icon when drag starts

With PointerChoreographer enabled, call setPointerIcon instead of
setPointerIconType.

Test: Manual
Bug: 293587049
Change-Id: I28130e7786b46c05735305c150572286e576ebdf
parent 6c7aa6f2
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -162,6 +162,8 @@ interface IWindowSession {
     * @param flags See {@code View#startDragAndDrop}
     * @param surface Surface containing drag shadow image
     * @param touchSource See {@code InputDevice#getSource()}
     * @param touchDeviceId device ID of last touch event
     * @param pointerId pointer ID of last touch event
     * @param touchX X coordinate of last touch point
     * @param touchY Y coordinate of last touch point
     * @param thumbCenterX X coordinate for the position within the shadow image that should be
@@ -171,9 +173,9 @@ interface IWindowSession {
     * @param data Data transferred by drag and drop
     * @return Token of drag operation which will be passed to cancelDragAndDrop.
     */
    @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
    IBinder performDrag(IWindow window, int flags, in SurfaceControl surface, int touchSource,
            float touchX, float touchY, float thumbCenterX, float thumbCenterY, in ClipData data);
            int touchDeviceId, int touchPointerId, float touchX, float touchY, float thumbCenterX,
            float thumbCenterY, in ClipData data);

    /**
     * Drops the content of the current drag operation for accessibility
+4 −1
Original line number Diff line number Diff line
@@ -28340,6 +28340,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                IBinder token = mAttachInfo.mSession.performDrag(
                        mAttachInfo.mWindow, flags, null,
                        mAttachInfo.mViewRootImpl.getLastTouchSource(),
                        mAttachInfo.mViewRootImpl.getLastTouchDeviceId(),
                        mAttachInfo.mViewRootImpl.getLastTouchPointerId(),
                        0f, 0f, 0f, 0f, data);
                if (ViewDebug.DEBUG_DRAG) {
                    Log.d(VIEW_LOG_TAG, "startDragAndDrop via a11y action returned " + token);
@@ -28414,7 +28416,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            }
            token = mAttachInfo.mSession.performDrag(mAttachInfo.mWindow, flags, surfaceControl,
                    root.getLastTouchSource(), lastTouchPoint.x, lastTouchPoint.y,
                    root.getLastTouchSource(), root.getLastTouchDeviceId(),
                    root.getLastTouchPointerId(), lastTouchPoint.x, lastTouchPoint.y,
                    shadowTouchPoint.x, shadowTouchPoint.y, data);
            if (ViewDebug.DEBUG_DRAG) {
                Log.d(VIEW_LOG_TAG, "performDrag returned " + token);
+12 −0
Original line number Diff line number Diff line
@@ -808,6 +808,8 @@ public final class ViewRootImpl implements ViewParent,
    final PointF mDragPoint = new PointF();
    final PointF mLastTouchPoint = new PointF();
    int mLastTouchSource;
    int mLastTouchDeviceId = KeyCharacterMap.VIRTUAL_KEYBOARD;
    int mLastTouchPointerId;
    /** Tracks last {@link MotionEvent#getToolType(int)} with {@link MotionEvent#ACTION_UP}. **/
    private int mLastClickToolType;

@@ -7098,6 +7100,8 @@ public final class ViewRootImpl implements ViewParent,
                mLastTouchPoint.x = event.getRawX();
                mLastTouchPoint.y = event.getRawY();
                mLastTouchSource = event.getSource();
                mLastTouchDeviceId = event.getDeviceId();
                mLastTouchPointerId = event.getPointerId(0);

                // Register last ACTION_UP. This will be propagated to IME.
                if (event.getActionMasked() == MotionEvent.ACTION_UP) {
@@ -8509,6 +8513,14 @@ public final class ViewRootImpl implements ViewParent,
        return mLastTouchSource;
    }

    public int getLastTouchDeviceId() {
        return mLastTouchDeviceId;
    }

    public int getLastTouchPointerId() {
        return mLastTouchPointerId;
    }

    /**
     * Used by InputMethodManager.
     * @hide
+3 −2
Original line number Diff line number Diff line
@@ -488,8 +488,9 @@ public class WindowlessWindowManager implements IWindowSession {

    @Override
    public android.os.IBinder performDrag(android.view.IWindow window, int flags,
            android.view.SurfaceControl surface, int touchSource, float touchX, float touchY,
            float thumbCenterX, float thumbCenterY, android.content.ClipData data) {
            android.view.SurfaceControl surface, int touchSource, int touchDeviceId,
            int touchPointerId, float touchX, float touchY, float thumbCenterX, float thumbCenterY,
            android.content.ClipData data) {
        return null;
    }

+17 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.wm;

import static com.android.input.flags.Flags.enablePointerChoreographer;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_DRAG;
import static com.android.server.wm.WindowManagerDebugConfig.SHOW_LIGHT_TRANSACTIONS;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
@@ -23,6 +24,7 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import android.annotation.NonNull;
import android.content.ClipData;
import android.content.Context;
import android.hardware.input.InputManagerGlobal;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
@@ -31,6 +33,8 @@ import android.os.Message;
import android.util.Slog;
import android.view.Display;
import android.view.IWindow;
import android.view.InputDevice;
import android.view.PointerIcon;
import android.view.SurfaceControl;
import android.view.View;
import android.view.accessibility.AccessibilityManager;
@@ -97,8 +101,8 @@ class DragDropController {
    }

    IBinder performDrag(int callerPid, int callerUid, IWindow window, int flags,
            SurfaceControl surface, int touchSource, float touchX, float touchY,
            float thumbCenterX, float thumbCenterY, ClipData data) {
            SurfaceControl surface, int touchSource, int touchDeviceId, int touchPointerId,
            float touchX, float touchY, float thumbCenterX, float thumbCenterY, ClipData data) {
        if (DEBUG_DRAG) {
            Slog.d(TAG_WM, "perform drag: win=" + window + " surface=" + surface + " flags=" +
                    Integer.toHexString(flags) + " data=" + data + " touch(" + touchX + ","
@@ -208,7 +212,17 @@ class DragDropController {

                final SurfaceControl surfaceControl = mDragState.mSurfaceControl;
                mDragState.broadcastDragStartedLocked(touchX, touchY);
                if (enablePointerChoreographer()) {
                    if ((touchSource & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE) {
                        InputManagerGlobal.getInstance().setPointerIcon(
                                PointerIcon.getSystemIcon(
                                        mService.mContext, PointerIcon.TYPE_GRABBING),
                                mDragState.mDisplayContent.getDisplayId(), touchDeviceId,
                                touchPointerId, mDragState.getInputToken());
                    }
                } else {
                    mDragState.overridePointerIconLocked(touchSource);
                }
                // remember the thumb offsets for later
                mDragState.mThumbOffsetX = thumbCenterX;
                mDragState.mThumbOffsetY = thumbCenterY;
Loading