Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 12f4ebd5 authored by Orhan Uysal's avatar Orhan Uysal
Browse files

Create a shortcut desktop to fullscreen.

Create necessary hooks for desktop to fullscreen keyboard shortcut.
Since both desktop to fullscreen and split to fullscreen will be using
the same keyboard shortcut combine both on the StatusBarManager side as
moveFocusedTasktoFullscreen.

Test: atest DesktopTasksController
Test: Manually trigger the shortcut to move from desktop to fullscreen
Test: Manually trigger the shortcut to move from split to fullscreen
Bug: 326061209
Flag: ACONFIG com.android.wm.shell.enable_desktop_windowing DEVELOPMENT
Change-Id: Ic5f8af23f55e30c971c115a20960f7336beb8629
parent 076de20c
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -360,8 +360,12 @@ oneway interface IStatusBar
    /** Shows rear display educational dialog */
    void showRearDisplayDialog(int currentBaseState);

    /** Called when requested to go to fullscreen from the active split app. */
    void goToFullscreenFromSplit();
    /**
     *  Called when requested to go to fullscreen from the focused app.
     *
     *  @param displayId the id of the current display.
     */
    void moveFocusedTaskToFullscreen(int displayId);

    /**
     * Enters stage split from a current running app.
+2 −0
Original line number Diff line number Diff line
@@ -51,4 +51,6 @@ public interface DesktopMode {
    /** Called when requested to go to desktop mode from the current focused app. */
    void enterDesktop(int displayId);

    /** Called when requested to go to fullscreen from the current focused desktop app. */
    void moveFocusedTaskToFullscreen(int displayId);
}
+18 −0
Original line number Diff line number Diff line
@@ -381,6 +381,18 @@ class DesktopTasksController(
        }
    }

    /** Enter fullscreen by moving the focused freeform task in given `displayId` to fullscreen. */
    fun enterFullscreen(displayId: Int) {
        if (DesktopModeStatus.isEnabled()) {
            shellTaskOrganizer
                    .getRunningTasks(displayId)
                    .find { taskInfo ->
                        taskInfo.isFocused && taskInfo.windowingMode == WINDOWING_MODE_FREEFORM
                    }
                    ?.let { moveToFullscreenWithAnimation(it, it.positionInParent) }
        }
    }

    /** Move a desktop app to split screen. */
    fun moveToSplit(task: RunningTaskInfo) {
        KtProtoLog.v(
@@ -1108,6 +1120,12 @@ class DesktopTasksController(
                this@DesktopTasksController.enterDesktop(displayId)
            }
        }

        override fun moveFocusedTaskToFullscreen(displayId: Int) {
            mainExecutor.execute {
                this@DesktopTasksController.enterFullscreen(displayId)
            }
        }
    }

    /** The interface for calls from outside the host process. */
+3 −1
Original line number Diff line number Diff line
@@ -476,8 +476,10 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
    }

    public void goToFullscreenFromSplit() {
        if (mStageCoordinator.isSplitActive()) {
            mStageCoordinator.goToFullscreenFromSplit();
        }
    }

    /** Move the specified task to fullscreen, regardless of focus state. */
    public void moveTaskToFullscreen(int taskId, int exitReason) {
+17 −0
Original line number Diff line number Diff line
@@ -781,6 +781,23 @@ class DesktopTasksControllerTest : ShellTestCase() {
        )
    }

    @Test
    fun moveFocusedTaskToFullscreen() {
        val task1 = setUpFreeformTask()
        val task2 = setUpFreeformTask()
        val task3 = setUpFreeformTask()

        task1.isFocused = false
        task2.isFocused = true
        task3.isFocused = false

        controller.enterFullscreen(DEFAULT_DISPLAY)

        val wct = getLatestExitDesktopWct()
        assertThat(wct.changes[task2.token.asBinder()]?.windowingMode)
                .isEqualTo(WINDOWING_MODE_FULLSCREEN)
    }

    private fun setUpFreeformTask(displayId: Int = DEFAULT_DISPLAY): RunningTaskInfo {
        val task = createFreeformTask(displayId)
        whenever(shellTaskOrganizer.getRunningTaskInfo(task.taskId)).thenReturn(task)
Loading