summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorMady Mellor <madym@google.com>2015-04-17 18:14:43 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-04-17 18:14:50 +0000
commit62b5b02c4f80bed47f8e2c542d4aa2d7bbeb7c08 (patch)
treeefbb2d4b12815f741f07ce016e3111c3caf41f1c /services
parentccc9b7f85c9fa583816d2bd04832626736591773 (diff)
parente40d785b7ab7aba533862181abcd95e06de13eb9 (diff)
downloadframeworks_base-62b5b02c4f80bed47f8e2c542d4aa2d7bbeb7c08.zip
frameworks_base-62b5b02c4f80bed47f8e2c542d4aa2d7bbeb7c08.tar.gz
frameworks_base-62b5b02c4f80bed47f8e2c542d4aa2d7bbeb7c08.tar.bz2
Merge "Drag n drop for stylus"
Diffstat (limited to 'services')
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java33
1 files changed, 30 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 964dcc2..f29d524 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -709,6 +709,11 @@ public class WindowManagerService extends IWindowManager.Stub
private WindowContentFrameStats mTempWindowRenderStats;
final class DragInputEventReceiver extends InputEventReceiver {
+ // Set, if stylus button was down at the start of the drag.
+ private boolean mStylusButtonDownAtStart;
+ // Indicates the first event to check for button state.
+ private boolean mIsStartEvent = true;
+
public DragInputEventReceiver(InputChannel inputChannel, Looper looper) {
super(inputChannel, looper);
}
@@ -724,6 +729,18 @@ public class WindowManagerService extends IWindowManager.Stub
boolean endDrag = false;
final float newX = motionEvent.getRawX();
final float newY = motionEvent.getRawY();
+ final boolean isStylusButtonDown =
+ (motionEvent.getToolType(0) == MotionEvent.TOOL_TYPE_STYLUS)
+ && (motionEvent.getButtonState() & MotionEvent.BUTTON_SECONDARY) != 0;
+
+ if (mIsStartEvent) {
+ if (isStylusButtonDown) {
+ // First event and the button was down, check for the button being
+ // lifted in the future, if that happens we'll drop the item.
+ mStylusButtonDownAtStart = true;
+ }
+ mIsStartEvent = false;
+ }
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN: {
@@ -733,9 +750,17 @@ public class WindowManagerService extends IWindowManager.Stub
} break;
case MotionEvent.ACTION_MOVE: {
- synchronized (mWindowMap) {
- // move the surface and tell the involved window(s) where we are
- mDragState.notifyMoveLw(newX, newY);
+ if (mStylusButtonDownAtStart && !isStylusButtonDown) {
+ if (DEBUG_DRAG) Slog.d(TAG, "Button no longer pressed; dropping at "
+ + newX + "," + newY);
+ synchronized (mWindowMap) {
+ endDrag = mDragState.notifyDropLw(newX, newY);
+ }
+ } else {
+ synchronized (mWindowMap) {
+ // move the surface and tell the involved window(s) where we are
+ mDragState.notifyMoveLw(newX, newY);
+ }
}
} break;
@@ -759,6 +784,8 @@ public class WindowManagerService extends IWindowManager.Stub
synchronized (mWindowMap) {
mDragState.endDragLw();
}
+ mStylusButtonDownAtStart = false;
+ mIsStartEvent = true;
}
handled = true;