diff --git a/api/current.xml b/api/current.xml index 016dd954b410a..01ce5720ef1f5 100644 --- a/api/current.xml +++ b/api/current.xml @@ -217895,10 +217895,10 @@ - - + + - + diff --git a/core/java/android/view/IWindowSession.aidl b/core/java/android/view/IWindowSession.aidl index 23fae426c5a00..a5f405aca1e40 100644 --- a/core/java/android/view/IWindowSession.aidl +++ b/core/java/android/view/IWindowSession.aidl @@ -121,7 +121,7 @@ interface IWindowSession { * the drag to the OS and passes that as the return value. A return value of * null indicates failure. */ - IBinder prepareDrag(IWindow window, boolean localOnly, + IBinder prepareDrag(IWindow window, int flags, int thumbnailWidth, int thumbnailHeight, out Surface outSurface); /** diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 703084ff14467..39ec26d24ecaf 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -2137,6 +2137,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility */ boolean mCanAcceptDrop; + /** + * Flag indicating that a drag can cross window boundaries + * @hide + */ + public static final int DRAG_FLAG_GLOBAL = 1; + /** * Position of the vertical scroll bar. */ @@ -10633,22 +10639,21 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility * * @param data !!! TODO * @param shadowBuilder !!! TODO - * @param myWindowOnly When {@code true}, indicates that the drag operation should be - * restricted to the calling application. In this case only the calling application - * will see any DragEvents related to this drag operation. * @param myLocalState An arbitrary object that will be passed as part of every DragEvent * delivered to the calling application during the course of the current drag operation. * This object is private to the application that called startDrag(), and is not * visible to other applications. It provides a lightweight way for the application to * propagate information from the initiator to the recipient of a drag within its own * application; for example, to help disambiguate between 'copy' and 'move' semantics. + * @param flags Flags affecting the drag operation. At present no flags are defined; + * pass 0 for this parameter. * @return {@code true} if the drag operation was initiated successfully; {@code false} if * an error prevented the drag from taking place. */ public final boolean startDrag(ClipData data, DragShadowBuilder shadowBuilder, - boolean myWindowOnly, Object myLocalState) { + Object myLocalState, int flags) { if (ViewDebug.DEBUG_DRAG) { - Log.d(VIEW_LOG_TAG, "startDrag: data=" + data + " local=" + myWindowOnly); + Log.d(VIEW_LOG_TAG, "startDrag: data=" + data + " flags=" + flags); } boolean okay = false; @@ -10668,7 +10673,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility Surface surface = new Surface(); try { IBinder token = mAttachInfo.mSession.prepareDrag(mAttachInfo.mWindow, - myWindowOnly, shadowSize.x, shadowSize.y, surface); + flags, shadowSize.x, shadowSize.y, surface); if (ViewDebug.DEBUG_DRAG) Log.d(VIEW_LOG_TAG, "prepareDrag returned token=" + token + " surface=" + surface); if (token != null) { diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index a1c286fb1ca46..b892fe213591f 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -8104,7 +8104,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener CharSequence selectedText = mTransformed.subSequence(start, end); ClipData data = ClipData.newPlainText(null, null, selectedText); DragLocalState localState = new DragLocalState(this, start, end); - startDrag(data, getTextThumbnailBuilder(selectedText), false, localState); + startDrag(data, getTextThumbnailBuilder(selectedText), localState, 0); stopSelectionActionMode(); } else { updateSelectedRegion(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/ShirtPocket.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/ShirtPocket.java index b9206eada0fb9..2ebd067a2675b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/ShirtPocket.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/ShirtPocket.java @@ -163,7 +163,7 @@ public class ShirtPocket extends ImageView { shadow = new DragShadowBuilder(mWindow.findViewById(R.id.preview)); } - v.startDrag(clip, shadow, false, null); + v.startDrag(clip, shadow, null, 0); // TODO: only discard the clipping if it was accepted stash(null); diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index 5c823bae8aa40..7011f9a130911 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -493,7 +493,7 @@ public class WindowManagerService extends IWindowManager.Stub class DragState { IBinder mToken; Surface mSurface; - boolean mLocalOnly; + int mFlags; IBinder mLocalWin; ClipData mData; ClipDescription mDataDescription; @@ -507,10 +507,10 @@ public class WindowManagerService extends IWindowManager.Stub private final Rect tmpRect = new Rect(); - DragState(IBinder token, Surface surface, boolean localOnly, IBinder localWin) { + DragState(IBinder token, Surface surface, int flags, IBinder localWin) { mToken = token; mSurface = surface; - mLocalOnly = localOnly; + mFlags = flags; mLocalWin = localWin; mNotifiedWindows = new ArrayList(); } @@ -520,7 +520,7 @@ public class WindowManagerService extends IWindowManager.Stub mSurface.destroy(); } mSurface = null; - mLocalOnly = false; + mFlags = 0; mLocalWin = null; mToken = null; mData = null; @@ -593,7 +593,7 @@ public class WindowManagerService extends IWindowManager.Stub ClipDescription desc) { // Don't actually send the event if the drag is supposed to be pinned // to the originating window but 'newWin' is not that window. - if (mLocalOnly) { + if ((mFlags & View.DRAG_FLAG_GLOBAL) == 0) { final IBinder winBinder = newWin.mClient.asBinder(); if (winBinder != mLocalWin) { if (DEBUG_DRAG) { @@ -681,7 +681,7 @@ public class WindowManagerService extends IWindowManager.Stub // Tell the affected window WindowState touchedWin = getTouchedWinAtPointLw(x, y); - if (mLocalOnly) { + 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 @@ -5633,10 +5633,10 @@ public class WindowManagerService extends IWindowManager.Stub // ------------------------------------------------------------- IBinder prepareDragSurface(IWindow window, SurfaceSession session, - boolean localOnly, int width, int height, Surface outSurface) { + int flags, int width, int height, Surface outSurface) { if (DEBUG_DRAG) { Slog.d(TAG, "prepare drag surface: w=" + width + " h=" + height - + " local=" + localOnly + " win=" + window + + " flags=" + Integer.toHexString(flags) + " win=" + window + " asbinder=" + window.asBinder()); } @@ -5647,17 +5647,15 @@ public class WindowManagerService extends IWindowManager.Stub try { synchronized (mWindowMap) { try { - // !!! TODO: fail if the given window does not currently have touch focus? - if (mDragState == null) { Surface surface = new Surface(session, callerPid, "drag surface", 0, width, height, PixelFormat.TRANSLUCENT, Surface.HIDDEN); outSurface.copyFrom(surface); final IBinder winBinder = window.asBinder(); token = new Binder(); - mDragState = new DragState(token, surface, localOnly, winBinder); + // TODO: preserve flags param in DragState + mDragState = new DragState(token, surface, 0, winBinder); mDragState.mSurface = surface; - mDragState.mLocalOnly = localOnly; token = mDragState.mToken = new Binder(); // 5 second timeout for this window to actually begin the drag @@ -6412,9 +6410,9 @@ public class WindowManagerService extends IWindowManager.Stub } /* Drag/drop */ - public IBinder prepareDrag(IWindow window, boolean localOnly, + public IBinder prepareDrag(IWindow window, int flags, int width, int height, Surface outSurface) { - return prepareDragSurface(window, mSurfaceSession, localOnly, + return prepareDragSurface(window, mSurfaceSession, flags, width, height, outSurface); } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java index 74e5a65607d65..ff46e7c68b040 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java @@ -106,7 +106,7 @@ public final class BridgeWindowSession implements IWindowSession { // pass for now. } - public IBinder prepareDrag(IWindow window, boolean localOnly, + public IBinder prepareDrag(IWindow window, int flags, int thumbnailWidth, int thumbnailHeight, Surface outSurface) throws RemoteException { // pass for now