Merge "Exit desktop mode on dragging a task to the top of the screen." into tm-qpr-dev

This commit is contained in:
Matt Sziklay
2022-09-28 23:30:28 +00:00
committed by Android (Google) Code Review
3 changed files with 38 additions and 5 deletions

View File

@@ -188,14 +188,16 @@ public abstract class WMShellModule {
@ShellMainThread Choreographer mainChoreographer, @ShellMainThread Choreographer mainChoreographer,
ShellTaskOrganizer taskOrganizer, ShellTaskOrganizer taskOrganizer,
DisplayController displayController, DisplayController displayController,
SyncTransactionQueue syncQueue) { SyncTransactionQueue syncQueue,
@DynamicOverride DesktopModeController desktopModeController) {
return new CaptionWindowDecorViewModel( return new CaptionWindowDecorViewModel(
context, context,
mainHandler, mainHandler,
mainChoreographer, mainChoreographer,
taskOrganizer, taskOrganizer,
displayController, displayController,
syncQueue); syncQueue,
desktopModeController);
} }
// //

View File

@@ -176,6 +176,25 @@ public class DesktopModeController implements RemoteCallable<DesktopModeControll
mShellTaskOrganizer.applyTransaction(wct); mShellTaskOrganizer.applyTransaction(wct);
} }
/**
* Turn desktop mode on or off
* @param active the desired state for desktop mode setting
*/
public void setDesktopModeActive(boolean active) {
int value = active ? 1 : 0;
Settings.System.putInt(mContext.getContentResolver(), Settings.System.DESKTOP_MODE, value);
}
/**
* Returns the windowing mode of the display area with the specified displayId.
* @param displayId
* @return
*/
public int getDisplayAreaWindowingMode(int displayId) {
return mRootTaskDisplayAreaOrganizer.getDisplayAreaInfo(displayId)
.configuration.windowConfiguration.getWindowingMode();
}
/** /**
* A {@link ContentObserver} for listening to changes to {@link Settings.System#DESKTOP_MODE} * A {@link ContentObserver} for listening to changes to {@link Settings.System#DESKTOP_MODE}
*/ */

View File

@@ -37,6 +37,7 @@ import com.android.wm.shell.R;
import com.android.wm.shell.ShellTaskOrganizer; import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.SyncTransactionQueue; import com.android.wm.shell.common.SyncTransactionQueue;
import com.android.wm.shell.desktopmode.DesktopModeController;
import com.android.wm.shell.desktopmode.DesktopModeStatus; import com.android.wm.shell.desktopmode.DesktopModeStatus;
import com.android.wm.shell.freeform.FreeformTaskTransitionStarter; import com.android.wm.shell.freeform.FreeformTaskTransitionStarter;
import com.android.wm.shell.transition.Transitions; import com.android.wm.shell.transition.Transitions;
@@ -54,6 +55,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel<Caption
private final DisplayController mDisplayController; private final DisplayController mDisplayController;
private final SyncTransactionQueue mSyncQueue; private final SyncTransactionQueue mSyncQueue;
private FreeformTaskTransitionStarter mTransitionStarter; private FreeformTaskTransitionStarter mTransitionStarter;
private DesktopModeController mDesktopModeController;
public CaptionWindowDecorViewModel( public CaptionWindowDecorViewModel(
Context context, Context context,
@@ -61,7 +63,8 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel<Caption
Choreographer mainChoreographer, Choreographer mainChoreographer,
ShellTaskOrganizer taskOrganizer, ShellTaskOrganizer taskOrganizer,
DisplayController displayController, DisplayController displayController,
SyncTransactionQueue syncQueue) { SyncTransactionQueue syncQueue,
DesktopModeController desktopModeController) {
mContext = context; mContext = context;
mMainHandler = mainHandler; mMainHandler = mainHandler;
mMainChoreographer = mainChoreographer; mMainChoreographer = mainChoreographer;
@@ -69,6 +72,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel<Caption
mTaskOrganizer = taskOrganizer; mTaskOrganizer = taskOrganizer;
mDisplayController = displayController; mDisplayController = displayController;
mSyncQueue = syncQueue; mSyncQueue = syncQueue;
mDesktopModeController = desktopModeController;
} }
@Override @Override
@@ -211,8 +215,10 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel<Caption
} }
private void handleEventForMove(MotionEvent e) { private void handleEventForMove(MotionEvent e) {
if (mTaskOrganizer.getRunningTaskInfo(mTaskId).getWindowingMode() RunningTaskInfo taskInfo = mTaskOrganizer.getRunningTaskInfo(mTaskId);
== WINDOWING_MODE_FULLSCREEN) { int windowingMode = mDesktopModeController
.getDisplayAreaWindowingMode(taskInfo.displayId);
if (windowingMode == WINDOWING_MODE_FULLSCREEN) {
return; return;
} }
switch (e.getActionMasked()) { switch (e.getActionMasked()) {
@@ -230,8 +236,14 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel<Caption
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL: { case MotionEvent.ACTION_CANCEL: {
int dragPointerIdx = e.findPointerIndex(mDragPointerId); int dragPointerIdx = e.findPointerIndex(mDragPointerId);
int statusBarHeight = mDisplayController.getDisplayLayout(taskInfo.displayId)
.stableInsets().top;
mDragResizeCallback.onDragResizeEnd( mDragResizeCallback.onDragResizeEnd(
e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx)); e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx));
if (e.getRawY(dragPointerIdx) <= statusBarHeight
&& windowingMode == WINDOWING_MODE_FREEFORM) {
mDesktopModeController.setDesktopModeActive(false);
}
break; break;
} }
} }