Bug 1561927 - Ignore weird motion event on Chrome OS. r=geckoview-reviewers,agi

Android app on Chrome OS doesn't use scroll event on touch pad scroll. And
this generate wired mouse event via it.

So we should add a workaround like Blink (https://crbug.com/704051).

Differential Revision: https://phabricator.services.mozilla.com/D110058
This commit is contained in:
Makoto Kato 2021-04-06 22:50:03 +00:00
parent 356e2d8209
commit a6a94c7a07

View File

@ -481,6 +481,19 @@ public class PanZoomController {
return mPointerScrollFactor;
}
/**
* This is a workaround for touch pad on Android app by Chrome OS.
* Android app on Chrome OS fires weird motion event by two finger scroll.
* See https://crbug.com/704051
*/
private boolean mayTouchpadScroll(final @NonNull MotionEvent event) {
final int action = event.getActionMasked();
return event.getButtonState() == 0 &&
(action == MotionEvent.ACTION_DOWN ||
(mLastDownTime == event.getDownTime() &&
(action == MotionEvent.ACTION_MOVE || action == MotionEvent.ACTION_UP)));
}
/**
* Process a touch event through the pan-zoom controller. Treat any mouse events as
* "touch" rather than as "mouse". Pointer coordinates should be relative to the
@ -491,7 +504,7 @@ public class PanZoomController {
public void onTouchEvent(final @NonNull MotionEvent event) {
ThreadUtils.assertOnUiThread();
if (!sTreatMouseAsTouch && event.getToolType(0) == MotionEvent.TOOL_TYPE_MOUSE) {
if (!sTreatMouseAsTouch && event.getToolType(0) == MotionEvent.TOOL_TYPE_MOUSE && !mayTouchpadScroll(event)) {
handleMouseEvent(event);
return;
}
@ -534,7 +547,7 @@ public class PanZoomController {
public @NonNull GeckoResult<InputResultDetail> onTouchEventForDetailResult(final @NonNull MotionEvent event) {
ThreadUtils.assertOnUiThread();
if (!sTreatMouseAsTouch && event.getToolType(0) == MotionEvent.TOOL_TYPE_MOUSE) {
if (!sTreatMouseAsTouch && event.getToolType(0) == MotionEvent.TOOL_TYPE_MOUSE && !mayTouchpadScroll(event)) {
return GeckoResult.fromValue(
new InputResultDetail(handleMouseEvent(event), SCROLLABLE_FLAG_NONE, OVERSCROLL_FLAG_NONE));
}