Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java +11 −4 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import static android.view.InputDevice.SOURCE_TOUCHSCREEN; import static android.view.MotionEvent.ACTION_CANCEL; import static android.view.MotionEvent.ACTION_HOVER_ENTER; import static android.view.MotionEvent.ACTION_HOVER_EXIT; import static android.view.MotionEvent.ACTION_MOVE; import static android.view.MotionEvent.ACTION_UP; import static android.view.WindowInsets.Type.statusBars; Loading Loading @@ -493,6 +494,12 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { (int) e.getRawX(), (int) e.getRawY()); final boolean isTransparentCaption = TaskInfoKt.isTransparentCaptionBarAppearance(decoration.mTaskInfo); // MotionEvent's coordinates are relative to view, we want location in window // to offset position relative to caption as a whole. int[] viewLocation = new int[2]; v.getLocationInWindow(viewLocation); final boolean isResizeEvent = decoration.shouldResizeListenerHandleEvent(e, new Point(viewLocation[0], viewLocation[1])); // The caption window may be a spy window when the caption background is // transparent, which means events will fall through to the app window. Make // sure to cancel these events if they do not happen in the intersection of the Loading @@ -500,11 +507,11 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { // the drag-move or other caption gestures should take priority outside those // regions. mShouldPilferCaptionEvents = !(downInCustomizableCaptionRegion && downInExclusionRegion && isTransparentCaption); && downInExclusionRegion && isTransparentCaption) && !isResizeEvent; } if (!mShouldPilferCaptionEvents) { // The event will be handled by a window below. // The event will be handled by a window below or pilfered by resize handler. return false; } // Otherwise pilfer so that windows below receive cancellations for this gesture, and Loading Loading @@ -604,7 +611,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { // prevent the button's ripple effect from showing. return !touchingButton; } case MotionEvent.ACTION_MOVE: { case ACTION_MOVE: { // If a decor's resize drag zone is active, don't also try to reposition it. if (decoration.isHandlingDragResize()) break; decoration.closeMaximizeMenu(); Loading Loading @@ -863,7 +870,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { break; } case MotionEvent.ACTION_MOVE: { case ACTION_MOVE: { if (relevantDecor == null) { return; } Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java +4 −0 Original line number Diff line number Diff line Loading @@ -421,6 +421,10 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin return mHandleMenu != null; } boolean shouldResizeListenerHandleEvent(MotionEvent e, Point offset) { return mDragResizeListener.shouldHandleEvent(e, offset); } boolean isHandlingDragResize() { return mDragResizeListener != null && mDragResizeListener.isHandlingDragResize(); } Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragResizeInputListener.java +29 −9 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import static com.android.wm.shell.windowdecor.DragPositioningCallback.CTRL_TYPE import static com.android.wm.shell.windowdecor.DragPositioningCallback.CTRL_TYPE_TOP; import android.content.Context; import android.graphics.Point; import android.graphics.Rect; import android.graphics.Region; import android.hardware.input.InputManager; Loading Loading @@ -321,6 +322,10 @@ class DragResizeInputListener implements AutoCloseable { } } boolean shouldHandleEvent(MotionEvent e, Point offset) { return mInputEventReceiver.shouldHandleEvent(e, offset); } boolean isHandlingDragResize() { return mInputEventReceiver.isHandlingEvents(); } Loading Loading @@ -408,18 +413,14 @@ class DragResizeInputListener implements AutoCloseable { boolean result = false; // Check if this is a touch event vs mouse event. // Touch events are tracked in four corners. Other events are tracked in resize edges. boolean isTouch = (e.getSource() & SOURCE_TOUCHSCREEN) == SOURCE_TOUCHSCREEN; boolean isTouch = isTouchEvent(e); switch (e.getActionMasked()) { case MotionEvent.ACTION_DOWN: { float x = e.getX(0); float y = e.getY(0); if (isTouch) { mShouldHandleEvents = isInCornerBounds(x, y); } else { mShouldHandleEvents = isInResizeHandleBounds(x, y); } mShouldHandleEvents = shouldHandleEvent(e, isTouch, new Point() /* offset */); if (mShouldHandleEvents) { mDragPointerId = e.getPointerId(0); float x = e.getX(0); float y = e.getY(0); float rawX = e.getRawX(0); float rawY = e.getRawY(0); int ctrlType = calculateCtrlType(isTouch, x, y); Loading Loading @@ -447,7 +448,6 @@ class DragResizeInputListener implements AutoCloseable { } case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: { mInputManager.pilferPointers(mInputChannel.getToken()); if (mShouldHandleEvents) { int dragPointerIndex = e.findPointerIndex(mDragPointerId); final Rect taskBounds = mCallback.onDragPositioningEnd( Loading Loading @@ -638,5 +638,25 @@ class DragResizeInputListener implements AutoCloseable { mLastCursorType = cursorType; } } private boolean shouldHandleEvent(MotionEvent e, Point offset) { return shouldHandleEvent(e, isTouchEvent(e), offset); } private boolean shouldHandleEvent(MotionEvent e, boolean isTouch, Point offset) { boolean result; final float x = e.getX(0) + offset.x; final float y = e.getY(0) + offset.y; if (isTouch) { result = isInCornerBounds(x, y); } else { result = isInResizeHandleBounds(x, y); } return result; } private boolean isTouchEvent(MotionEvent e) { return (e.getSource() & SOURCE_TOUCHSCREEN) == SOURCE_TOUCHSCREEN; } } } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java +11 −4 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import static android.view.InputDevice.SOURCE_TOUCHSCREEN; import static android.view.MotionEvent.ACTION_CANCEL; import static android.view.MotionEvent.ACTION_HOVER_ENTER; import static android.view.MotionEvent.ACTION_HOVER_EXIT; import static android.view.MotionEvent.ACTION_MOVE; import static android.view.MotionEvent.ACTION_UP; import static android.view.WindowInsets.Type.statusBars; Loading Loading @@ -493,6 +494,12 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { (int) e.getRawX(), (int) e.getRawY()); final boolean isTransparentCaption = TaskInfoKt.isTransparentCaptionBarAppearance(decoration.mTaskInfo); // MotionEvent's coordinates are relative to view, we want location in window // to offset position relative to caption as a whole. int[] viewLocation = new int[2]; v.getLocationInWindow(viewLocation); final boolean isResizeEvent = decoration.shouldResizeListenerHandleEvent(e, new Point(viewLocation[0], viewLocation[1])); // The caption window may be a spy window when the caption background is // transparent, which means events will fall through to the app window. Make // sure to cancel these events if they do not happen in the intersection of the Loading @@ -500,11 +507,11 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { // the drag-move or other caption gestures should take priority outside those // regions. mShouldPilferCaptionEvents = !(downInCustomizableCaptionRegion && downInExclusionRegion && isTransparentCaption); && downInExclusionRegion && isTransparentCaption) && !isResizeEvent; } if (!mShouldPilferCaptionEvents) { // The event will be handled by a window below. // The event will be handled by a window below or pilfered by resize handler. return false; } // Otherwise pilfer so that windows below receive cancellations for this gesture, and Loading Loading @@ -604,7 +611,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { // prevent the button's ripple effect from showing. return !touchingButton; } case MotionEvent.ACTION_MOVE: { case ACTION_MOVE: { // If a decor's resize drag zone is active, don't also try to reposition it. if (decoration.isHandlingDragResize()) break; decoration.closeMaximizeMenu(); Loading Loading @@ -863,7 +870,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { break; } case MotionEvent.ACTION_MOVE: { case ACTION_MOVE: { if (relevantDecor == null) { return; } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java +4 −0 Original line number Diff line number Diff line Loading @@ -421,6 +421,10 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin return mHandleMenu != null; } boolean shouldResizeListenerHandleEvent(MotionEvent e, Point offset) { return mDragResizeListener.shouldHandleEvent(e, offset); } boolean isHandlingDragResize() { return mDragResizeListener != null && mDragResizeListener.isHandlingDragResize(); } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragResizeInputListener.java +29 −9 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import static com.android.wm.shell.windowdecor.DragPositioningCallback.CTRL_TYPE import static com.android.wm.shell.windowdecor.DragPositioningCallback.CTRL_TYPE_TOP; import android.content.Context; import android.graphics.Point; import android.graphics.Rect; import android.graphics.Region; import android.hardware.input.InputManager; Loading Loading @@ -321,6 +322,10 @@ class DragResizeInputListener implements AutoCloseable { } } boolean shouldHandleEvent(MotionEvent e, Point offset) { return mInputEventReceiver.shouldHandleEvent(e, offset); } boolean isHandlingDragResize() { return mInputEventReceiver.isHandlingEvents(); } Loading Loading @@ -408,18 +413,14 @@ class DragResizeInputListener implements AutoCloseable { boolean result = false; // Check if this is a touch event vs mouse event. // Touch events are tracked in four corners. Other events are tracked in resize edges. boolean isTouch = (e.getSource() & SOURCE_TOUCHSCREEN) == SOURCE_TOUCHSCREEN; boolean isTouch = isTouchEvent(e); switch (e.getActionMasked()) { case MotionEvent.ACTION_DOWN: { float x = e.getX(0); float y = e.getY(0); if (isTouch) { mShouldHandleEvents = isInCornerBounds(x, y); } else { mShouldHandleEvents = isInResizeHandleBounds(x, y); } mShouldHandleEvents = shouldHandleEvent(e, isTouch, new Point() /* offset */); if (mShouldHandleEvents) { mDragPointerId = e.getPointerId(0); float x = e.getX(0); float y = e.getY(0); float rawX = e.getRawX(0); float rawY = e.getRawY(0); int ctrlType = calculateCtrlType(isTouch, x, y); Loading Loading @@ -447,7 +448,6 @@ class DragResizeInputListener implements AutoCloseable { } case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: { mInputManager.pilferPointers(mInputChannel.getToken()); if (mShouldHandleEvents) { int dragPointerIndex = e.findPointerIndex(mDragPointerId); final Rect taskBounds = mCallback.onDragPositioningEnd( Loading Loading @@ -638,5 +638,25 @@ class DragResizeInputListener implements AutoCloseable { mLastCursorType = cursorType; } } private boolean shouldHandleEvent(MotionEvent e, Point offset) { return shouldHandleEvent(e, isTouchEvent(e), offset); } private boolean shouldHandleEvent(MotionEvent e, boolean isTouch, Point offset) { boolean result; final float x = e.getX(0) + offset.x; final float y = e.getY(0) + offset.y; if (isTouch) { result = isInCornerBounds(x, y); } else { result = isInResizeHandleBounds(x, y); } return result; } private boolean isTouchEvent(MotionEvent e) { return (e.getSource() & SOURCE_TOUCHSCREEN) == SOURCE_TOUCHSCREEN; } } }