Search in sources :

Example 16 with DragEvent

use of android.view.DragEvent in project android_frameworks_base by DirtyUnicorns.

the class DragState method notifyDropLw.

// Find the drop target and tell it about the data.  Returns 'true' if we can immediately
// dispatch the global drag-ended message, 'false' if we need to wait for a
// result from the recipient.
boolean notifyDropLw(float x, float y) {
    if (mAnimation != null) {
        return false;
    }
    mCurrentX = x;
    mCurrentY = y;
    WindowState touchedWin = mDisplayContent.getTouchableWinAtPointLocked(x, y);
    if (!isWindowNotified(touchedWin)) {
        // "drop" outside a valid window -- no recipient to apply a
        // timeout to, and we can send the drag-ended message immediately.
        mDragResult = false;
        return true;
    }
    if (DEBUG_DRAG) {
        Slog.d(TAG_WM, "sending DROP to " + touchedWin);
    }
    final int targetUserId = UserHandle.getUserId(touchedWin.getOwningUid());
    DragAndDropPermissionsHandler dragAndDropPermissions = null;
    if ((mFlags & View.DRAG_FLAG_GLOBAL) != 0 && (mFlags & DRAG_FLAGS_URI_ACCESS) != 0) {
        dragAndDropPermissions = new DragAndDropPermissionsHandler(mData, mUid, touchedWin.getOwningPackage(), mFlags & DRAG_FLAGS_URI_PERMISSIONS, mSourceUserId, targetUserId);
    }
    if (mSourceUserId != targetUserId) {
        mData.fixUris(mSourceUserId);
    }
    final int myPid = Process.myPid();
    final IBinder token = touchedWin.mClient.asBinder();
    DragEvent evt = obtainDragEvent(touchedWin, DragEvent.ACTION_DROP, x, y, null, null, mData, dragAndDropPermissions, false);
    try {
        touchedWin.mClient.dispatchDragEvent(evt);
        // 5 second timeout for this window to respond to the drop
        mService.mH.removeMessages(H.DRAG_END_TIMEOUT, token);
        Message msg = mService.mH.obtainMessage(H.DRAG_END_TIMEOUT, token);
        mService.mH.sendMessageDelayed(msg, 5000);
    } catch (RemoteException e) {
        Slog.w(TAG_WM, "can't send drop notification to win " + touchedWin);
        return true;
    } finally {
        if (myPid != touchedWin.mSession.mPid) {
            evt.recycle();
        }
    }
    mToken = token;
    return false;
}
Also used : DragEvent(android.view.DragEvent) IBinder(android.os.IBinder) Message(android.os.Message) RemoteException(android.os.RemoteException) Point(android.graphics.Point)

Example 17 with DragEvent

use of android.view.DragEvent in project android_frameworks_base by DirtyUnicorns.

the class DragState method notifyLocationLw.

void notifyLocationLw(float x, float y) {
    // Tell the affected window
    WindowState touchedWin = mDisplayContent.getTouchableWinAtPointLocked(x, y);
    if (touchedWin != null && !isWindowNotified(touchedWin)) {
        // The drag point is over a window which was not notified about a drag start.
        // Pretend it's over empty space.
        touchedWin = null;
    }
    try {
        final int myPid = Process.myPid();
        // have we dragged over a new window?
        if ((touchedWin != mTargetWindow) && (mTargetWindow != null)) {
            if (DEBUG_DRAG) {
                Slog.d(TAG_WM, "sending DRAG_EXITED to " + mTargetWindow);
            }
            // force DRAG_EXITED_EVENT if appropriate
            DragEvent evt = obtainDragEvent(mTargetWindow, DragEvent.ACTION_DRAG_EXITED, 0, 0, null, null, null, null, false);
            mTargetWindow.mClient.dispatchDragEvent(evt);
            if (myPid != mTargetWindow.mSession.mPid) {
                evt.recycle();
            }
        }
        if (touchedWin != null) {
            if (false && DEBUG_DRAG) {
                Slog.d(TAG_WM, "sending DRAG_LOCATION to " + touchedWin);
            }
            DragEvent evt = obtainDragEvent(touchedWin, DragEvent.ACTION_DRAG_LOCATION, x, y, null, null, null, null, false);
            touchedWin.mClient.dispatchDragEvent(evt);
            if (myPid != touchedWin.mSession.mPid) {
                evt.recycle();
            }
        }
    } catch (RemoteException e) {
        Slog.w(TAG_WM, "can't send drag notification to windows");
    }
    mTargetWindow = touchedWin;
}
Also used : DragEvent(android.view.DragEvent) RemoteException(android.os.RemoteException) Point(android.graphics.Point)

Example 18 with DragEvent

use of android.view.DragEvent in project android_frameworks_base by ResurrectionRemix.

the class DragState method sendDragStartedLw.

/* helper - send a ACTION_DRAG_STARTED event, if the
     * designated window is potentially a drop recipient.  There are race situations
     * around DRAG_ENDED broadcast, so we make sure that once we've declared that
     * the drag has ended, we never send out another DRAG_STARTED for this drag action.
     *
     * This method clones the 'event' parameter if it's being delivered to the same
     * process, so it's safe for the caller to call recycle() on the event afterwards.
     */
private void sendDragStartedLw(WindowState newWin, float touchX, float touchY, ClipDescription desc) {
    if (mDragInProgress && isValidDropTarget(newWin)) {
        DragEvent event = obtainDragEvent(newWin, DragEvent.ACTION_DRAG_STARTED, touchX, touchY, null, desc, null, null, false);
        try {
            newWin.mClient.dispatchDragEvent(event);
            // track each window that we've notified that the drag is starting
            mNotifiedWindows.add(newWin);
        } catch (RemoteException e) {
            Slog.w(TAG_WM, "Unable to drag-start window " + newWin);
        } finally {
            // if the callee was local, the dispatch has already recycled the event
            if (Process.myPid() != newWin.mSession.mPid) {
                event.recycle();
            }
        }
    }
}
Also used : DragEvent(android.view.DragEvent) RemoteException(android.os.RemoteException)

Example 19 with DragEvent

use of android.view.DragEvent in project android_frameworks_base by crdroidandroid.

the class DragState method sendDragStartedLw.

/* helper - send a ACTION_DRAG_STARTED event, if the
     * designated window is potentially a drop recipient.  There are race situations
     * around DRAG_ENDED broadcast, so we make sure that once we've declared that
     * the drag has ended, we never send out another DRAG_STARTED for this drag action.
     *
     * This method clones the 'event' parameter if it's being delivered to the same
     * process, so it's safe for the caller to call recycle() on the event afterwards.
     */
private void sendDragStartedLw(WindowState newWin, float touchX, float touchY, ClipDescription desc) {
    if (mDragInProgress && isValidDropTarget(newWin)) {
        DragEvent event = obtainDragEvent(newWin, DragEvent.ACTION_DRAG_STARTED, touchX, touchY, null, desc, null, null, false);
        try {
            newWin.mClient.dispatchDragEvent(event);
            // track each window that we've notified that the drag is starting
            mNotifiedWindows.add(newWin);
        } catch (RemoteException e) {
            Slog.w(TAG_WM, "Unable to drag-start window " + newWin);
        } finally {
            // if the callee was local, the dispatch has already recycled the event
            if (Process.myPid() != newWin.mSession.mPid) {
                event.recycle();
            }
        }
    }
}
Also used : DragEvent(android.view.DragEvent) RemoteException(android.os.RemoteException)

Example 20 with DragEvent

use of android.view.DragEvent in project android_frameworks_base by crdroidandroid.

the class DragState method notifyDropLw.

// Find the drop target and tell it about the data.  Returns 'true' if we can immediately
// dispatch the global drag-ended message, 'false' if we need to wait for a
// result from the recipient.
boolean notifyDropLw(float x, float y) {
    if (mAnimation != null) {
        return false;
    }
    mCurrentX = x;
    mCurrentY = y;
    WindowState touchedWin = mDisplayContent.getTouchableWinAtPointLocked(x, y);
    if (!isWindowNotified(touchedWin)) {
        // "drop" outside a valid window -- no recipient to apply a
        // timeout to, and we can send the drag-ended message immediately.
        mDragResult = false;
        return true;
    }
    if (DEBUG_DRAG) {
        Slog.d(TAG_WM, "sending DROP to " + touchedWin);
    }
    final int targetUserId = UserHandle.getUserId(touchedWin.getOwningUid());
    DragAndDropPermissionsHandler dragAndDropPermissions = null;
    if ((mFlags & View.DRAG_FLAG_GLOBAL) != 0 && (mFlags & DRAG_FLAGS_URI_ACCESS) != 0) {
        dragAndDropPermissions = new DragAndDropPermissionsHandler(mData, mUid, touchedWin.getOwningPackage(), mFlags & DRAG_FLAGS_URI_PERMISSIONS, mSourceUserId, targetUserId);
    }
    if (mSourceUserId != targetUserId) {
        mData.fixUris(mSourceUserId);
    }
    final int myPid = Process.myPid();
    final IBinder token = touchedWin.mClient.asBinder();
    DragEvent evt = obtainDragEvent(touchedWin, DragEvent.ACTION_DROP, x, y, null, null, mData, dragAndDropPermissions, false);
    try {
        touchedWin.mClient.dispatchDragEvent(evt);
        // 5 second timeout for this window to respond to the drop
        mService.mH.removeMessages(H.DRAG_END_TIMEOUT, token);
        Message msg = mService.mH.obtainMessage(H.DRAG_END_TIMEOUT, token);
        mService.mH.sendMessageDelayed(msg, 5000);
    } catch (RemoteException e) {
        Slog.w(TAG_WM, "can't send drop notification to win " + touchedWin);
        return true;
    } finally {
        if (myPid != touchedWin.mSession.mPid) {
            evt.recycle();
        }
    }
    mToken = token;
    return false;
}
Also used : DragEvent(android.view.DragEvent) IBinder(android.os.IBinder) Message(android.os.Message) RemoteException(android.os.RemoteException) Point(android.graphics.Point)

Aggregations

RemoteException (android.os.RemoteException)20 DragEvent (android.view.DragEvent)20 Point (android.graphics.Point)14 IBinder (android.os.IBinder)7 Message (android.os.Message)5