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

Commit c8680438 authored by Vladislav Kaznacheev's avatar Vladislav Kaznacheev Committed by Android (Google) Code Review
Browse files

Merge "Change mouse pointer when drag and drop is active"

parents 8d4d5c1c ba761124
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -186,8 +186,8 @@ interface IWindowSession {
    /**
     * Initiate the drag operation itself
     */
    boolean performDrag(IWindow window, IBinder dragToken, float touchX, float touchY,
            float thumbCenterX, float thumbCenterY, in ClipData data);
    boolean performDrag(IWindow window, IBinder dragToken, int touchSource,
            float touchX, float touchY, float thumbCenterX, float thumbCenterY, in ClipData data);

   /**
     * Report the result of a drop action targeted to the given window.
+1 −1
Original line number Diff line number Diff line
@@ -20059,7 +20059,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                root.getLastTouchPoint(shadowSize);
                okay = mAttachInfo.mSession.performDrag(mAttachInfo.mWindow, mAttachInfo.mDragToken,
                        shadowSize.x, shadowSize.y,
                        root.getLastTouchSource(), shadowSize.x, shadowSize.y,
                        shadowTouchPoint.x, shadowTouchPoint.y, data);
                if (ViewDebug.DEBUG_DRAG) Log.d(VIEW_LOG_TAG, "performDrag returned " + okay);
            }
+6 −0
Original line number Diff line number Diff line
@@ -339,6 +339,7 @@ public final class ViewRootImpl implements ViewParent,
    volatile Object mLocalDragState;
    final PointF mDragPoint = new PointF();
    final PointF mLastTouchPoint = new PointF();
    int mLastTouchSource;

    private boolean mProfileRendering;
    private Choreographer.FrameCallback mRenderProfiler;
@@ -4122,6 +4123,7 @@ public final class ViewRootImpl implements ViewParent,
            if (event.isTouchEvent()) {
                mLastTouchPoint.x = event.getRawX();
                mLastTouchPoint.y = event.getRawY();
                mLastTouchSource = event.getSource();
            }
            return FORWARD;
        }
@@ -5475,6 +5477,10 @@ public final class ViewRootImpl implements ViewParent,
        outLocation.y = (int) mLastTouchPoint.y;
    }

    public int getLastTouchSource() {
        return mLastTouchSource;
    }

    public void setDragFocus(View newDragTarget) {
        if (mCurrentDragView != newDragTarget) {
            mCurrentDragView = newDragTarget;
+22 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.graphics.Matrix;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Region;
import android.hardware.input.InputManager;
import android.os.IBinder;
import android.os.Message;
import android.os.Process;
@@ -36,6 +37,8 @@ import android.util.Slog;
import android.view.Display;
import android.view.DragEvent;
import android.view.InputChannel;
import android.view.InputDevice;
import android.view.PointerIcon;
import android.view.SurfaceControl;
import android.view.View;
import android.view.WindowManager;
@@ -72,6 +75,7 @@ class DragState {
    int mUid;
    ClipData mData;
    ClipDescription mDataDescription;
    int mTouchSource;
    boolean mDragResult;
    float mOriginalAlpha;
    float mOriginalX, mOriginalY;
@@ -342,6 +346,7 @@ class DragState {

    private void cleanUpDragLw() {
        broadcastDragEndedLw();
        restorePointerIconLw();

        // stop intercepting input
        unregister();
@@ -576,4 +581,21 @@ class DragState {
        set.start();  // Will start on the first call to getTransformation.
        return set;
    }

    private boolean isFromSource(int source) {
        return (mTouchSource & source) == source;
    }

    void overridePointerIconLw(int touchSource) {
        mTouchSource = touchSource;
        if (isFromSource(InputDevice.SOURCE_MOUSE)) {
            InputManager.getInstance().setPointerIconShape(PointerIcon.STYLE_GRAB);
        }
    }

    private void restorePointerIconLw() {
        if (isFromSource(InputDevice.SOURCE_MOUSE)) {
            InputManager.getInstance().setPointerIconShape(PointerIcon.STYLE_DEFAULT);
        }
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -283,7 +283,7 @@ final class Session extends IWindowSession.Stub
    }

    public boolean performDrag(IWindow window, IBinder dragToken,
            float touchX, float touchY, float thumbCenterX, float thumbCenterY,
            int touchSource, float touchX, float touchY, float thumbCenterX, float thumbCenterY,
            ClipData data) {
        if (DEBUG_DRAG) {
            Slog.d(TAG_WM, "perform drag: win=" + window + " data=" + data);
@@ -336,6 +336,7 @@ final class Session extends IWindowSession.Stub

            mService.mDragState.mData = data;
            mService.mDragState.broadcastDragStartedLw(touchX, touchY);
            mService.mDragState.overridePointerIconLw(touchSource);

            // remember the thumb offsets for later
            mService.mDragState.mThumbOffsetX = thumbCenterX;
Loading