Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java +13 −7 Original line number Diff line number Diff line Loading @@ -421,9 +421,9 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { } moveTaskToFront(mTaskOrganizer.getRunningTaskInfo(mTaskId)); if (!mHasLongClicked) { if (!mHasLongClicked && id != R.id.maximize_window) { final DesktopModeWindowDecoration decoration = mWindowDecorByTaskId.get(mTaskId); decoration.closeMaximizeMenu(); decoration.closeMaximizeMenuIfNeeded(e); } final long eventDuration = e.getEventTime() - e.getDownTime(); Loading Loading @@ -643,7 +643,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { handleCaptionThroughStatusBar(ev, relevantDecor); } } handleEventOutsideFocusedCaption(ev, relevantDecor); handleEventOutsideCaption(ev, relevantDecor); // Prevent status bar from reacting to a caption drag. if (DesktopModeStatus.isEnabled()) { if (mTransitionDragActive) { Loading @@ -652,11 +652,17 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { } } // If an UP/CANCEL action is received outside of caption bounds, turn off handle menu private void handleEventOutsideFocusedCaption(MotionEvent ev, /** * If an UP/CANCEL action is received outside of the caption bounds, close the handle and * maximize the menu. * * @param relevantDecor the window decoration of the focused task's caption. This method only * handles motion events outside this caption's bounds. */ private void handleEventOutsideCaption(MotionEvent ev, DesktopModeWindowDecoration relevantDecor) { // Returns if event occurs within caption if (relevantDecor == null || relevantDecor.checkTouchEventInCaptionHandle(ev)) { if (relevantDecor == null || relevantDecor.checkTouchEventInCaption(ev)) { return; } Loading Loading @@ -692,7 +698,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { } if (dragFromStatusBarAllowed && relevantDecor.checkTouchEventInCaptionHandle(ev)) { && relevantDecor.checkTouchEventInFocusedCaptionHandle(ev)) { mTransitionDragActive = true; } } Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java +21 −8 Original line number Diff line number Diff line Loading @@ -612,8 +612,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin void closeMaximizeMenuIfNeeded(MotionEvent ev) { if (!isMaximizeMenuActive()) return; final PointF inputPoint = offsetCaptionLocation(ev); if (!mMaximizeMenu.isValidMenuInput(inputPoint)) { if (!mMaximizeMenu.isValidMenuInput(ev)) { closeMaximizeMenu(); } } Loading @@ -639,20 +638,34 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin } /** * Checks if motion event occurs in the caption handle area. This should be used in cases where * Checks if motion event occurs in the caption handle area of a focused caption (the caption on * a task in fullscreen or in multi-windowing mode). This should be used in cases where * onTouchListener will not work (i.e. when caption is in status bar area). * * @param ev the {@link MotionEvent} to check * @return {@code true} if event is inside the specified view, {@code false} if not * @return {@code true} if event is inside caption handle view, {@code false} if not */ boolean checkTouchEventInCaptionHandle(MotionEvent ev) { boolean checkTouchEventInFocusedCaptionHandle(MotionEvent ev) { if (isHandleMenuActive() || !(mWindowDecorViewHolder instanceof DesktopModeFocusedWindowDecorationViewHolder)) { return false; } return checkTouchEventInCaption(ev); } /** * Checks if touch event occurs in caption. * * @param ev the {@link MotionEvent} to check * @return {@code true} if event is inside caption view, {@code false} if not */ boolean checkTouchEventInCaption(MotionEvent ev) { final PointF inputPoint = offsetCaptionLocation(ev); return ((DesktopModeFocusedWindowDecorationViewHolder) mWindowDecorViewHolder) .pointInCaption(inputPoint, mResult.mCaptionX); return inputPoint.x >= mResult.mCaptionX && inputPoint.x <= mResult.mCaptionX + mResult.mCaptionWidth && inputPoint.y >= 0 && inputPoint.y <= mResult.mCaptionHeight; } /** Loading @@ -668,7 +681,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin // Click if point in caption handle view final View caption = mResult.mRootView.findViewById(R.id.desktop_mode_caption); final View handle = caption.findViewById(R.id.caption_handle); if (checkTouchEventInCaptionHandle(ev)) { if (checkTouchEventInFocusedCaptionHandle(ev)) { mOnCaptionButtonClickListener.onClick(handle); } } else { Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/MaximizeMenu.kt +8 −11 Original line number Diff line number Diff line Loading @@ -22,10 +22,10 @@ import android.content.res.Resources import android.graphics.PixelFormat import android.graphics.PointF import android.view.LayoutInflater import android.view.MotionEvent import android.view.SurfaceControl import android.view.SurfaceControl.Transaction import android.view.SurfaceControlViewHost import android.view.View import android.view.View.OnClickListener import android.view.WindowManager import android.view.WindowlessWindowManager Loading Loading @@ -62,6 +62,8 @@ class MaximizeMenu( private val cornerRadius = loadDimensionPixelSize( R.dimen.desktop_mode_maximize_menu_corner_radius ).toFloat() private val menuWidth = loadDimensionPixelSize(R.dimen.desktop_mode_maximize_menu_width) private val menuHeight = loadDimensionPixelSize(R.dimen.desktop_mode_maximize_menu_height) /** Position the menu relative to the caption's position. */ fun positionMenu(position: PointF, t: Transaction) { Loading Loading @@ -95,8 +97,6 @@ class MaximizeMenu( .setName("Maximize Menu") .setContainerLayer() .build() val menuWidth = loadDimensionPixelSize(R.dimen.desktop_mode_maximize_menu_width) val menuHeight = loadDimensionPixelSize(R.dimen.desktop_mode_maximize_menu_height) val lp = WindowManager.LayoutParams( menuWidth, menuHeight, Loading Loading @@ -160,14 +160,11 @@ class MaximizeMenu( * * @param inputPoint the input to compare against. */ fun isValidMenuInput(inputPoint: PointF): Boolean { val menuView = maximizeMenu?.mWindowViewHost?.view ?: return true return !viewsLaidOut() || pointInView(menuView, inputPoint.x - menuPosition.x, inputPoint.y - menuPosition.y) } private fun pointInView(v: View, x: Float, y: Float): Boolean { return v.left <= x && v.right >= x && v.top <= y && v.bottom >= y fun isValidMenuInput(ev: MotionEvent): Boolean { val x = ev.rawX val y = ev.rawY return !viewsLaidOut() || (menuPosition.x <= x && menuPosition.x + menuWidth >= x && menuPosition.y <= y && menuPosition.y + menuHeight >= y) } /** Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java +7 −4 Original line number Diff line number Diff line Loading @@ -279,11 +279,12 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> } outResult.mCaptionHeight = loadDimensionPixelSize(resources, params.mCaptionHeightId); final int captionWidth = params.mCaptionWidthId != Resources.ID_NULL outResult.mCaptionWidth = params.mCaptionWidthId != Resources.ID_NULL ? loadDimensionPixelSize(resources, params.mCaptionWidthId) : taskBounds.width(); outResult.mCaptionX = (outResult.mWidth - captionWidth) / 2; outResult.mCaptionX = (outResult.mWidth - outResult.mCaptionWidth) / 2; startT.setWindowCrop(mCaptionContainerSurface, captionWidth, outResult.mCaptionHeight) startT.setWindowCrop(mCaptionContainerSurface, outResult.mCaptionWidth, outResult.mCaptionHeight) .setPosition(mCaptionContainerSurface, outResult.mCaptionX, 0 /* y */) .setLayer(mCaptionContainerSurface, CAPTION_LAYER_Z_ORDER) .show(mCaptionContainerSurface); Loading Loading @@ -356,7 +357,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> // Caption view mCaptionWindowManager.setConfiguration(taskConfig); final WindowManager.LayoutParams lp = new WindowManager.LayoutParams(captionWidth, outResult.mCaptionHeight, new WindowManager.LayoutParams(outResult.mCaptionWidth, outResult.mCaptionHeight, WindowManager.LayoutParams.TYPE_APPLICATION, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSPARENT); lp.setTitle("Caption of Task=" + mTaskInfo.taskId); Loading Loading @@ -578,6 +579,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> static class RelayoutResult<T extends View & TaskFocusStateConsumer> { int mCaptionHeight; int mCaptionWidth; int mCaptionX; int mWidth; int mHeight; Loading @@ -587,6 +589,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> mWidth = 0; mHeight = 0; mCaptionHeight = 0; mCaptionWidth = 0; mCaptionX = 0; mRootView = null; } Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeFocusedWindowDecorationViewHolder.kt +0 −12 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ import android.app.ActivityManager.RunningTaskInfo import android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM import android.content.res.ColorStateList import android.graphics.Color import android.graphics.PointF import android.view.View import android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS import android.widget.ImageButton Loading Loading @@ -47,17 +46,6 @@ internal class DesktopModeFocusedWindowDecorationViewHolder( animateCaptionHandleAlpha(startValue = 0f, endValue = 1f) } /** * Returns true if input point is in the caption's view. * @param inputPoint the input point relative to the task in full "focus" (i.e. fullscreen). */ fun pointInCaption(inputPoint: PointF, captionX: Int): Boolean { return inputPoint.x >= captionX && inputPoint.x <= captionX + captionView.width && inputPoint.y >= 0 && inputPoint.y <= captionView.height } private fun getCaptionHandleBarColor(taskInfo: RunningTaskInfo): Int { return if (shouldUseLightCaptionColors(taskInfo)) { context.getColor(R.color.desktop_mode_caption_handle_bar_light) Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java +13 −7 Original line number Diff line number Diff line Loading @@ -421,9 +421,9 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { } moveTaskToFront(mTaskOrganizer.getRunningTaskInfo(mTaskId)); if (!mHasLongClicked) { if (!mHasLongClicked && id != R.id.maximize_window) { final DesktopModeWindowDecoration decoration = mWindowDecorByTaskId.get(mTaskId); decoration.closeMaximizeMenu(); decoration.closeMaximizeMenuIfNeeded(e); } final long eventDuration = e.getEventTime() - e.getDownTime(); Loading Loading @@ -643,7 +643,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { handleCaptionThroughStatusBar(ev, relevantDecor); } } handleEventOutsideFocusedCaption(ev, relevantDecor); handleEventOutsideCaption(ev, relevantDecor); // Prevent status bar from reacting to a caption drag. if (DesktopModeStatus.isEnabled()) { if (mTransitionDragActive) { Loading @@ -652,11 +652,17 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { } } // If an UP/CANCEL action is received outside of caption bounds, turn off handle menu private void handleEventOutsideFocusedCaption(MotionEvent ev, /** * If an UP/CANCEL action is received outside of the caption bounds, close the handle and * maximize the menu. * * @param relevantDecor the window decoration of the focused task's caption. This method only * handles motion events outside this caption's bounds. */ private void handleEventOutsideCaption(MotionEvent ev, DesktopModeWindowDecoration relevantDecor) { // Returns if event occurs within caption if (relevantDecor == null || relevantDecor.checkTouchEventInCaptionHandle(ev)) { if (relevantDecor == null || relevantDecor.checkTouchEventInCaption(ev)) { return; } Loading Loading @@ -692,7 +698,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { } if (dragFromStatusBarAllowed && relevantDecor.checkTouchEventInCaptionHandle(ev)) { && relevantDecor.checkTouchEventInFocusedCaptionHandle(ev)) { mTransitionDragActive = true; } } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java +21 −8 Original line number Diff line number Diff line Loading @@ -612,8 +612,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin void closeMaximizeMenuIfNeeded(MotionEvent ev) { if (!isMaximizeMenuActive()) return; final PointF inputPoint = offsetCaptionLocation(ev); if (!mMaximizeMenu.isValidMenuInput(inputPoint)) { if (!mMaximizeMenu.isValidMenuInput(ev)) { closeMaximizeMenu(); } } Loading @@ -639,20 +638,34 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin } /** * Checks if motion event occurs in the caption handle area. This should be used in cases where * Checks if motion event occurs in the caption handle area of a focused caption (the caption on * a task in fullscreen or in multi-windowing mode). This should be used in cases where * onTouchListener will not work (i.e. when caption is in status bar area). * * @param ev the {@link MotionEvent} to check * @return {@code true} if event is inside the specified view, {@code false} if not * @return {@code true} if event is inside caption handle view, {@code false} if not */ boolean checkTouchEventInCaptionHandle(MotionEvent ev) { boolean checkTouchEventInFocusedCaptionHandle(MotionEvent ev) { if (isHandleMenuActive() || !(mWindowDecorViewHolder instanceof DesktopModeFocusedWindowDecorationViewHolder)) { return false; } return checkTouchEventInCaption(ev); } /** * Checks if touch event occurs in caption. * * @param ev the {@link MotionEvent} to check * @return {@code true} if event is inside caption view, {@code false} if not */ boolean checkTouchEventInCaption(MotionEvent ev) { final PointF inputPoint = offsetCaptionLocation(ev); return ((DesktopModeFocusedWindowDecorationViewHolder) mWindowDecorViewHolder) .pointInCaption(inputPoint, mResult.mCaptionX); return inputPoint.x >= mResult.mCaptionX && inputPoint.x <= mResult.mCaptionX + mResult.mCaptionWidth && inputPoint.y >= 0 && inputPoint.y <= mResult.mCaptionHeight; } /** Loading @@ -668,7 +681,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin // Click if point in caption handle view final View caption = mResult.mRootView.findViewById(R.id.desktop_mode_caption); final View handle = caption.findViewById(R.id.caption_handle); if (checkTouchEventInCaptionHandle(ev)) { if (checkTouchEventInFocusedCaptionHandle(ev)) { mOnCaptionButtonClickListener.onClick(handle); } } else { Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/MaximizeMenu.kt +8 −11 Original line number Diff line number Diff line Loading @@ -22,10 +22,10 @@ import android.content.res.Resources import android.graphics.PixelFormat import android.graphics.PointF import android.view.LayoutInflater import android.view.MotionEvent import android.view.SurfaceControl import android.view.SurfaceControl.Transaction import android.view.SurfaceControlViewHost import android.view.View import android.view.View.OnClickListener import android.view.WindowManager import android.view.WindowlessWindowManager Loading Loading @@ -62,6 +62,8 @@ class MaximizeMenu( private val cornerRadius = loadDimensionPixelSize( R.dimen.desktop_mode_maximize_menu_corner_radius ).toFloat() private val menuWidth = loadDimensionPixelSize(R.dimen.desktop_mode_maximize_menu_width) private val menuHeight = loadDimensionPixelSize(R.dimen.desktop_mode_maximize_menu_height) /** Position the menu relative to the caption's position. */ fun positionMenu(position: PointF, t: Transaction) { Loading Loading @@ -95,8 +97,6 @@ class MaximizeMenu( .setName("Maximize Menu") .setContainerLayer() .build() val menuWidth = loadDimensionPixelSize(R.dimen.desktop_mode_maximize_menu_width) val menuHeight = loadDimensionPixelSize(R.dimen.desktop_mode_maximize_menu_height) val lp = WindowManager.LayoutParams( menuWidth, menuHeight, Loading Loading @@ -160,14 +160,11 @@ class MaximizeMenu( * * @param inputPoint the input to compare against. */ fun isValidMenuInput(inputPoint: PointF): Boolean { val menuView = maximizeMenu?.mWindowViewHost?.view ?: return true return !viewsLaidOut() || pointInView(menuView, inputPoint.x - menuPosition.x, inputPoint.y - menuPosition.y) } private fun pointInView(v: View, x: Float, y: Float): Boolean { return v.left <= x && v.right >= x && v.top <= y && v.bottom >= y fun isValidMenuInput(ev: MotionEvent): Boolean { val x = ev.rawX val y = ev.rawY return !viewsLaidOut() || (menuPosition.x <= x && menuPosition.x + menuWidth >= x && menuPosition.y <= y && menuPosition.y + menuHeight >= y) } /** Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java +7 −4 Original line number Diff line number Diff line Loading @@ -279,11 +279,12 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> } outResult.mCaptionHeight = loadDimensionPixelSize(resources, params.mCaptionHeightId); final int captionWidth = params.mCaptionWidthId != Resources.ID_NULL outResult.mCaptionWidth = params.mCaptionWidthId != Resources.ID_NULL ? loadDimensionPixelSize(resources, params.mCaptionWidthId) : taskBounds.width(); outResult.mCaptionX = (outResult.mWidth - captionWidth) / 2; outResult.mCaptionX = (outResult.mWidth - outResult.mCaptionWidth) / 2; startT.setWindowCrop(mCaptionContainerSurface, captionWidth, outResult.mCaptionHeight) startT.setWindowCrop(mCaptionContainerSurface, outResult.mCaptionWidth, outResult.mCaptionHeight) .setPosition(mCaptionContainerSurface, outResult.mCaptionX, 0 /* y */) .setLayer(mCaptionContainerSurface, CAPTION_LAYER_Z_ORDER) .show(mCaptionContainerSurface); Loading Loading @@ -356,7 +357,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> // Caption view mCaptionWindowManager.setConfiguration(taskConfig); final WindowManager.LayoutParams lp = new WindowManager.LayoutParams(captionWidth, outResult.mCaptionHeight, new WindowManager.LayoutParams(outResult.mCaptionWidth, outResult.mCaptionHeight, WindowManager.LayoutParams.TYPE_APPLICATION, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSPARENT); lp.setTitle("Caption of Task=" + mTaskInfo.taskId); Loading Loading @@ -578,6 +579,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> static class RelayoutResult<T extends View & TaskFocusStateConsumer> { int mCaptionHeight; int mCaptionWidth; int mCaptionX; int mWidth; int mHeight; Loading @@ -587,6 +589,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> mWidth = 0; mHeight = 0; mCaptionHeight = 0; mCaptionWidth = 0; mCaptionX = 0; mRootView = null; } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeFocusedWindowDecorationViewHolder.kt +0 −12 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ import android.app.ActivityManager.RunningTaskInfo import android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM import android.content.res.ColorStateList import android.graphics.Color import android.graphics.PointF import android.view.View import android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS import android.widget.ImageButton Loading Loading @@ -47,17 +46,6 @@ internal class DesktopModeFocusedWindowDecorationViewHolder( animateCaptionHandleAlpha(startValue = 0f, endValue = 1f) } /** * Returns true if input point is in the caption's view. * @param inputPoint the input point relative to the task in full "focus" (i.e. fullscreen). */ fun pointInCaption(inputPoint: PointF, captionX: Int): Boolean { return inputPoint.x >= captionX && inputPoint.x <= captionX + captionView.width && inputPoint.y >= 0 && inputPoint.y <= captionView.height } private fun getCaptionHandleBarColor(taskInfo: RunningTaskInfo): Int { return if (shouldUseLightCaptionColors(taskInfo)) { context.getColor(R.color.desktop_mode_caption_handle_bar_light) Loading