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

Commit d0ed8937 authored by Vladislav Kaznacheev's avatar Vladislav Kaznacheev
Browse files

Send ACTION_DRAG_LOCATION right after ACTION_DRAG_STARTED

When an app is both drag and drop origin and recipient, it might not
get ACTION_DRAG_ENTERED in some cases. Specifically, when
mouse is long-pressed and released in place, the sequence
of drag events is: ACTION_DRAG_STARTED, ACTION_DROP,
ACTION_DRAG_ENDED. This is happening because
ACTION_DRAG_ENTERED is emitted from ACTION_DRAG_LOCATION
handler (which is never called since mouse has not moved).

This problem does not exist with touch because (at least according
to observable behavior on Nexus 9) when drag and drop is initiated
by touch, MotionEvent.ACTION_MOVE immediately follows
MotionEvent.ACTION_DOWN (which normally causes
View.startDragAndDrop).

This CL fixes this problem by sending a single ACTION_DRAG_LOCATION
right after ACTION_DRAG_STARTED.

Bug: 26566708
Change-Id: Ifc8dd1005c04a5c8f0dc3f14be9e4839204cf281
parent fadc8666
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -360,8 +360,6 @@ class DragState {
        mCurrentX = x;
        mCurrentY = y;

        final int myPid = Process.myPid();

        // Move the surface to the given touch
        if (SHOW_LIGHT_TRANSACTIONS) Slog.i(
                TAG_WM, ">>> OPEN TRANSACTION notifyMoveLw");
@@ -376,7 +374,10 @@ class DragState {
            if (SHOW_LIGHT_TRANSACTIONS) Slog.i(
                    TAG_WM, "<<< CLOSE TRANSACTION notifyMoveLw");
        }
        notifyLocationLw(x, y);
    }

    void notifyLocationLw(float x, float y) {
        // Tell the affected window
        WindowState touchedWin = getTouchedWinAtPointLw(x, y);
        if (touchedWin == null) {
@@ -392,6 +393,8 @@ class DragState {
            }
        }
        try {
            final int myPid = Process.myPid();

            // have we dragged over a new window?
            if ((touchedWin != mTargetWindow) && (mTargetWindow != null)) {
                if (DEBUG_DRAG) {
+2 −0
Original line number Diff line number Diff line
@@ -353,6 +353,8 @@ final class Session extends IWindowSession.Stub
                if (SHOW_LIGHT_TRANSACTIONS) Slog.i(
                        TAG_WM, "<<< CLOSE TRANSACTION performDrag");
            }

            mService.mDragState.notifyLocationLw(touchX, touchY);
        }

        return true;    // success!