Update DesktopModeTouchEventListener to correctly identify click events.

Fixes a bug where click inputs are considered drag inputs, preventing
onClick events from occurring.

Bug: 268396444
Test: Manual. Drag/click caption and confirm correct behavior.
Test: atest DragDetectorTest
Change-Id: I2990438e0d9f0c38738a65a0c36d18307d34fd2e
This commit is contained in:
mattsziklay
2023-02-08 11:40:30 -08:00
committed by Matt Sziklay
parent 7cf6cd8567
commit b45e67c06c
2 changed files with 23 additions and 14 deletions

View File

@@ -250,25 +250,30 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
@Override
public boolean onTouch(View v, MotionEvent e) {
boolean isDrag = false;
final int id = v.getId();
if (id != R.id.caption_handle && id != R.id.desktop_mode_caption) {
return false;
}
if (id == R.id.caption_handle) {
isDrag = mDragDetector.onMotionEvent(e);
switch (e.getAction()) {
case MotionEvent.ACTION_DOWN:
mDragDetector.onMotionEvent(e);
final RunningTaskInfo taskInfo = mTaskOrganizer.getRunningTaskInfo(mTaskId);
if (taskInfo.isFocused) {
return mDragDetector.isDragEvent();
}
final WindowContainerTransaction wct = new WindowContainerTransaction();
wct.reorder(mTaskToken, true /* onTop */);
mSyncQueue.queue(wct);
return false;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
boolean res = mDragDetector.isDragEvent();
mDragDetector.onMotionEvent(e);
return res;
default:
mDragDetector.onMotionEvent(e);
return mDragDetector.isDragEvent();
}
if (e.getAction() != MotionEvent.ACTION_DOWN) {
return isDrag;
}
final RunningTaskInfo taskInfo = mTaskOrganizer.getRunningTaskInfo(mTaskId);
if (taskInfo.isFocused) {
return isDrag;
}
final WindowContainerTransaction wct = new WindowContainerTransaction();
wct.reorder(mTaskToken, true /* onTop */);
mSyncQueue.queue(wct);
return true;
}
/**

View File

@@ -94,6 +94,10 @@ class DragDetector {
mTouchSlop = touchSlop;
}
boolean isDragEvent() {
return mIsDragEvent;
}
private void resetState() {
mIsDragEvent = false;
mInputDownPoint.set(0, 0);