}
Surface surface = new Surface();
try {
- mAttachInfo.mDragToken = mAttachInfo.mSession.prepareDrag(mAttachInfo.mWindow,
+ IBinder token = mAttachInfo.mSession.prepareDrag(mAttachInfo.mWindow,
flags, shadowSize.x, shadowSize.y, surface);
- if (ViewDebug.DEBUG_DRAG) Log.d(VIEW_LOG_TAG, "prepareDrag returned token="
- + mAttachInfo.mDragToken + " surface=" + surface);
- if (mAttachInfo.mDragToken != null) {
+ if (ViewDebug.DEBUG_DRAG) Log.d(VIEW_LOG_TAG, "prepareDrag returned token=" + token
+ + " surface=" + surface);
+ if (token != null) {
Canvas canvas = surface.lockCanvas(null);
try {
canvas.drawColor(0, PorterDuff.Mode.CLEAR);
// repurpose 'shadowSize' for the last touch point
root.getLastTouchPoint(shadowSize);
- okay = mAttachInfo.mSession.performDrag(mAttachInfo.mWindow, mAttachInfo.mDragToken,
+ okay = mAttachInfo.mSession.performDrag(mAttachInfo.mWindow, token,
shadowSize.x, shadowSize.y,
shadowTouchPoint.x, shadowTouchPoint.y, data);
if (ViewDebug.DEBUG_DRAG) Log.d(VIEW_LOG_TAG, "performDrag returned " + okay);
return okay;
}
- public final void cancelDrag() {
- if (ViewDebug.DEBUG_DRAG) {
- Log.d(VIEW_LOG_TAG, "cancelDrag");
- }
- if (mAttachInfo.mDragToken != null) {
- try {
- mAttachInfo.mSession.cancelDrag(mAttachInfo.mDragToken);
- } catch (Exception e) {
- Log.e(VIEW_LOG_TAG, "Unable to cancel drag", e);
- }
- mAttachInfo.mDragToken = null;
- } else {
- Log.e(VIEW_LOG_TAG, "No active drag to cancel");
- }
- }
-
/**
* Starts a move from {startX, startY}, the amount of the movement will be the offset
* between {startX, startY} and the new cursor positon.
View mViewRequestingLayout;
/**
- * Used to track the identity of the current drag operation.
- */
- IBinder mDragToken;
-
- /**
* Creates a new set of attachment information with the specified
* events handler and thread.
*
}
}
- public void cancelDrag(IBinder dragToken) {
- if (WindowManagerService.DEBUG_DRAG) {
- Slog.d(WindowManagerService.TAG, "cancel drag");
- }
-
- synchronized (mService.mWindowMap) {
- long ident = Binder.clearCallingIdentity();
- try {
- if (mService.mDragState == null) {
- Slog.w(WindowManagerService.TAG, "cancelDrag() without prepareDrag()");
- throw new IllegalStateException("cancelDrag() without prepareDrag()");
- }
-
- if (mService.mDragState.mToken != dragToken) {
- Slog.w(WindowManagerService.TAG, "cancelDrag() does not match prepareDrag()");
- throw new IllegalStateException("cancelDrag() does not match prepareDrag()");
- }
-
- mService.mDragState.mDragResult = false;
- mService.mDragState.endDragLw();
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
- }
-
public void dragRecipientEntered(IWindow window) {
if (WindowManagerService.DEBUG_DRAG) {
Slog.d(WindowManagerService.TAG, "Drag into new candidate view @ " + window.asBinder());