Skipping touch dispatch when it happens withing the window gesture region
> Those events are already proxied through the TouchInteractionService
Change-Id: If06483f208cbd462fdfdf01abba27bd937b766e7
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/fallback/RecentsRootView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/fallback/RecentsRootView.java
index 6b3f028..777e592 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/fallback/RecentsRootView.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/fallback/RecentsRootView.java
@@ -17,12 +17,18 @@
import android.annotation.TargetApi;
import android.content.Context;
+import android.graphics.Insets;
import android.graphics.Point;
import android.graphics.Rect;
+import android.graphics.RectF;
import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.ViewDebug;
+import android.view.WindowInsets;
import com.android.launcher3.BaseActivity;
import com.android.launcher3.R;
+import com.android.launcher3.Utilities;
import com.android.launcher3.util.Themes;
import com.android.launcher3.util.TouchController;
import com.android.launcher3.views.BaseDragLayer;
@@ -33,6 +39,9 @@
private static final int MIN_SIZE = 10;
private final RecentsActivity mActivity;
+ @ViewDebug.ExportedProperty(category = "launcher")
+ private final RectF mTouchExcludeRegion = new RectF();
+
private final Point mLastKnownSize = new Point(MIN_SIZE, MIN_SIZE);
public RecentsRootView(Context context, AttributeSet attrs) {
@@ -88,4 +97,29 @@
mActivity.getDeviceProfile().updateInsets(mInsets);
super.setInsets(mInsets);
}
+
+ @Override
+ public WindowInsets dispatchApplyWindowInsets(WindowInsets insets) {
+ if (Utilities.ATLEAST_Q) {
+ Insets gestureInsets = insets.getMandatorySystemGestureInsets();
+ mTouchExcludeRegion.set(gestureInsets.left, gestureInsets.top,
+ gestureInsets.right, gestureInsets.bottom);
+ }
+ return super.dispatchApplyWindowInsets(insets);
+ }
+
+ @Override
+ public boolean dispatchTouchEvent(MotionEvent ev) {
+ if (ev.getAction() == MotionEvent.ACTION_DOWN) {
+ float x = ev.getX();
+ float y = ev.getY();
+ if (y < mTouchExcludeRegion.top
+ || x < mTouchExcludeRegion.left
+ || x > (getWidth() - mTouchExcludeRegion.right)
+ || y > (getHeight() - mTouchExcludeRegion.bottom)) {
+ return false;
+ }
+ }
+ return super.dispatchTouchEvent(ev);
+ }
}
\ No newline at end of file
diff --git a/src/com/android/launcher3/LauncherRootView.java b/src/com/android/launcher3/LauncherRootView.java
index 9f6e5cd..e738eb7 100644
--- a/src/com/android/launcher3/LauncherRootView.java
+++ b/src/com/android/launcher3/LauncherRootView.java
@@ -8,11 +8,15 @@
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
+import android.graphics.Insets;
import android.graphics.Paint;
import android.graphics.Rect;
+import android.graphics.RectF;
import android.util.AttributeSet;
+import android.view.MotionEvent;
import android.view.View;
import android.view.ViewDebug;
+import android.view.WindowInsets;
public class LauncherRootView extends InsettableFrameLayout {
@@ -23,6 +27,9 @@
@ViewDebug.ExportedProperty(category = "launcher")
private final Rect mConsumedInsets = new Rect();
+ @ViewDebug.ExportedProperty(category = "launcher")
+ private final RectF mTouchExcludeRegion = new RectF();
+
private View mAlignedView;
private WindowStateListener mWindowStateListener;
@@ -145,6 +152,31 @@
}
}
+ @Override
+ public WindowInsets dispatchApplyWindowInsets(WindowInsets insets) {
+ if (Utilities.ATLEAST_Q) {
+ Insets gestureInsets = insets.getMandatorySystemGestureInsets();
+ mTouchExcludeRegion.set(gestureInsets.left, gestureInsets.top,
+ gestureInsets.right, gestureInsets.bottom);
+ }
+ return super.dispatchApplyWindowInsets(insets);
+ }
+
+ @Override
+ public boolean dispatchTouchEvent(MotionEvent ev) {
+ if (ev.getAction() == MotionEvent.ACTION_DOWN) {
+ float x = ev.getX();
+ float y = ev.getY();
+ if (y < mTouchExcludeRegion.top
+ || x < mTouchExcludeRegion.left
+ || x > (getWidth() - mTouchExcludeRegion.right)
+ || y > (getHeight() - mTouchExcludeRegion.bottom)) {
+ return false;
+ }
+ }
+ return super.dispatchTouchEvent(ev);
+ }
+
public interface WindowStateListener {
void onWindowFocusChanged(boolean hasFocus);