Constrain 'touch modal' behavior to the activity stack.

Currently a 'touch modal' window grabs drag events
from the entire screen. Since 'touch modal' is the
default, this makes dragging between apps impossible.

This change allows such grabbing behavior only for
events that are still over the same activity stack.

Bug:19548858
Change-Id: I7d48b58e7fcb620521361e17cb70914913afae03
diff --git a/services/core/java/com/android/server/wm/DragState.java b/services/core/java/com/android/server/wm/DragState.java
index c6951bd..1a125d4 100644
--- a/services/core/java/com/android/server/wm/DragState.java
+++ b/services/core/java/com/android/server/wm/DragState.java
@@ -24,6 +24,7 @@
 import android.content.ClipData;
 import android.content.ClipDescription;
 import android.graphics.Point;
+import android.graphics.Rect;
 import android.graphics.Region;
 import android.os.IBinder;
 import android.os.Message;
@@ -63,6 +64,7 @@
     Display mDisplay;
 
     private final Region mTmpRegion = new Region();
+    private final Rect mTmpRect = new Rect();
 
     DragState(WindowManagerService service, IBinder token, SurfaceControl surface,
             int flags, IBinder localWin) {
@@ -411,6 +413,12 @@
                 continue;
             }
 
+            child.getStackBounds(mTmpRect);
+            if (!mTmpRect.contains(x, y)) {
+                // outside of this window's activity stack == don't tell about drags
+                continue;
+            }
+
             child.getTouchableRegion(mTmpRegion);
 
             final int touchFlags = flags &