Use cursor position from mouse events for hit test

Otherwise user may accidentally trigger task resizing when performing
multi-finger gestures on touchpads.

Bug: 166337994
Test: handleTapOutsideTask() is skipped on touchpad gestures.
Change-Id: I5251623addb3d10af4c1735ce2a6b919a511460f
This commit is contained in:
Garfield Tan
2020-09-08 16:43:48 -07:00
parent 1043401f94
commit d1bf6f87ea

View File

@@ -25,6 +25,7 @@ import static android.view.PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW;
import android.graphics.Rect;
import android.graphics.Region;
import android.hardware.input.InputManager;
import android.view.InputDevice;
import android.view.MotionEvent;
import android.view.WindowManagerPolicyConstants.PointerEventListener;
@@ -62,8 +63,15 @@ public class TaskTapPointerEventListener implements PointerEventListener {
public void onPointerEvent(MotionEvent motionEvent) {
switch (motionEvent.getActionMasked()) {
case MotionEvent.ACTION_DOWN: {
final int x = (int) motionEvent.getX();
final int y = (int) motionEvent.getY();
final int x;
final int y;
if (motionEvent.getSource() == InputDevice.SOURCE_MOUSE) {
x = (int) motionEvent.getXCursorPosition();
y = (int) motionEvent.getYCursorPosition();
} else {
x = (int) motionEvent.getX();
y = (int) motionEvent.getY();
}
synchronized (this) {
if (!mTouchExcludeRegion.contains(x, y)) {