Search in sources :

Example 11 with DragEvent

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

the class DragState method broadcastDragEndedLw.

private void broadcastDragEndedLw() {
    final int myPid = Process.myPid();
    if (DEBUG_DRAG) {
        Slog.d(TAG_WM, "broadcasting DRAG_ENDED");
    }
    for (WindowState ws : mNotifiedWindows) {
        float x = 0;
        float y = 0;
        if (!mDragResult && (ws.mSession.mPid == mPid)) {
            // Report unconsumed drop location back to the app that started the drag.
            x = mCurrentX;
            y = mCurrentY;
        }
        DragEvent evt = DragEvent.obtain(DragEvent.ACTION_DRAG_ENDED, x, y, null, null, null, null, mDragResult);
        try {
            ws.mClient.dispatchDragEvent(evt);
        } catch (RemoteException e) {
            Slog.w(TAG_WM, "Unable to drag-end window " + ws);
        }
        // the dispatch has already recycled the event
        if (myPid != ws.mSession.mPid) {
            evt.recycle();
        }
    }
    mNotifiedWindows.clear();
    mDragInProgress = false;
}
Also used : DragEvent(android.view.DragEvent) RemoteException(android.os.RemoteException) Point(android.graphics.Point)

Example 12 with DragEvent

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

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 13 with DragEvent

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

the class DragState method broadcastDragEndedLw.

private void broadcastDragEndedLw() {
    final int myPid = Process.myPid();
    if (DEBUG_DRAG) {
        Slog.d(TAG_WM, "broadcasting DRAG_ENDED");
    }
    for (WindowState ws : mNotifiedWindows) {
        float x = 0;
        float y = 0;
        if (!mDragResult && (ws.mSession.mPid == mPid)) {
            // Report unconsumed drop location back to the app that started the drag.
            x = mCurrentX;
            y = mCurrentY;
        }
        DragEvent evt = DragEvent.obtain(DragEvent.ACTION_DRAG_ENDED, x, y, null, null, null, null, mDragResult);
        try {
            ws.mClient.dispatchDragEvent(evt);
        } catch (RemoteException e) {
            Slog.w(TAG_WM, "Unable to drag-end window " + ws);
        }
        // the dispatch has already recycled the event
        if (myPid != ws.mSession.mPid) {
            evt.recycle();
        }
    }
    mNotifiedWindows.clear();
    mDragInProgress = false;
}
Also used : DragEvent(android.view.DragEvent) RemoteException(android.os.RemoteException) Point(android.graphics.Point)

Example 14 with DragEvent

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

the class DragState method notifyMoveLw.

void notifyMoveLw(float x, float y) {
    final int myPid = Process.myPid();
    // Move the surface to the given touch
    if (WindowManagerService.SHOW_LIGHT_TRANSACTIONS)
        Slog.i(WindowManagerService.TAG, ">>> OPEN TRANSACTION notifyMoveLw");
    SurfaceControl.openTransaction();
    try {
        mSurfaceControl.setPosition(x - mThumbOffsetX, y - mThumbOffsetY);
        if (WindowManagerService.SHOW_TRANSACTIONS)
            Slog.i(WindowManagerService.TAG, "  DRAG " + mSurfaceControl + ": pos=(" + (int) (x - mThumbOffsetX) + "," + (int) (y - mThumbOffsetY) + ")");
    } finally {
        SurfaceControl.closeTransaction();
        if (WindowManagerService.SHOW_LIGHT_TRANSACTIONS)
            Slog.i(WindowManagerService.TAG, "<<< CLOSE TRANSACTION notifyMoveLw");
    }
    // Tell the affected window
    WindowState touchedWin = getTouchedWinAtPointLw(x, y);
    if (touchedWin == null) {
        if (WindowManagerService.DEBUG_DRAG)
            Slog.d(WindowManagerService.TAG, "No touched win at x=" + x + " y=" + y);
        return;
    }
    if ((mFlags & View.DRAG_FLAG_GLOBAL) == 0) {
        final IBinder touchedBinder = touchedWin.mClient.asBinder();
        if (touchedBinder != mLocalWin) {
            // This drag is pinned only to the originating window, but the drag
            // point is outside that window.  Pretend it's over empty space.
            touchedWin = null;
        }
    }
    try {
        // have we dragged over a new window?
        if ((touchedWin != mTargetWindow) && (mTargetWindow != null)) {
            if (WindowManagerService.DEBUG_DRAG) {
                Slog.d(WindowManagerService.TAG, "sending DRAG_EXITED to " + mTargetWindow);
            }
            // force DRAG_EXITED_EVENT if appropriate
            DragEvent evt = obtainDragEvent(mTargetWindow, DragEvent.ACTION_DRAG_EXITED, x, y, null, null, null, false);
            mTargetWindow.mClient.dispatchDragEvent(evt);
            if (myPid != mTargetWindow.mSession.mPid) {
                evt.recycle();
            }
        }
        if (touchedWin != null) {
            if (false && WindowManagerService.DEBUG_DRAG) {
                Slog.d(WindowManagerService.TAG, "sending DRAG_LOCATION to " + touchedWin);
            }
            DragEvent evt = obtainDragEvent(touchedWin, DragEvent.ACTION_DRAG_LOCATION, x, y, null, null, null, false);
            touchedWin.mClient.dispatchDragEvent(evt);
            if (myPid != touchedWin.mSession.mPid) {
                evt.recycle();
            }
        }
    } catch (RemoteException e) {
        Slog.w(WindowManagerService.TAG, "can't send drag notification to windows");
    }
    mTargetWindow = touchedWin;
}
Also used : DragEvent(android.view.DragEvent) IBinder(android.os.IBinder) RemoteException(android.os.RemoteException) Point(android.graphics.Point)

Example 15 with DragEvent

use of android.view.DragEvent in project platform_frameworks_base by android.

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)

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