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

Commit c4b4a430 authored by Alp Yalcin's avatar Alp Yalcin Committed by Android (Google) Code Review
Browse files

Merge changes I59ae22de,Id145a070 into main

* changes:
  [2/n] Inherit parent's bounds on tab tearing
  [1/n] Create flag for the new tab tearing feature
parents e6b3b930 5286e0c3
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -179,6 +179,9 @@ public enum DesktopExperienceFlags {
    ENABLE_INORDER_TRANSITION_CALLBACKS_FOR_DESKTOP(
            Flags::enableInorderTransitionCallbacksForDesktop, false,
            Flags.FLAG_ENABLE_INORDER_TRANSITION_CALLBACKS_FOR_DESKTOP),
    ENABLE_INTERACTION_DEPENDENT_TAB_TEARING_BOUNDS(
            Flags::enableInteractionDependentTabTearingBounds, false,
            Flags.FLAG_ENABLE_INTERACTION_DEPENDENT_TAB_TEARING_BOUNDS),
    ENABLE_INTERACTIVE_PICTURE_IN_PICTURE(Flags::enableInteractivePictureInPicture, false,
            Flags.FLAG_ENABLE_INTERACTIVE_PICTURE_IN_PICTURE),
    ENABLE_KEYBOARD_SHORTCUTS_TO_SWITCH_DESKS(Flags::keyboardShortcutsToSwitchDesks, true,
+11 −0
Original line number Diff line number Diff line
@@ -996,6 +996,17 @@ flag {
    }
}

flag {
    name: "enable_interaction_dependent_tab_tearing_bounds"
    namespace: "lse_desktop_experience"
    description: "Update bounds of a torn tab and position it with respect to user /n"
                 "interactions such drag-drop location and existing size of the parent window."
    bug: "436502207"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "enable_interactive_picture_in_picture"
    namespace: "web_apps_on_chromeos_and_android"
+14 −6
Original line number Diff line number Diff line
@@ -5705,6 +5705,13 @@ class DesktopTasksController(
        when (indicatorType) {
            IndicatorType.TO_DESKTOP_INDICATOR,
            IndicatorType.NO_INDICATOR -> {
                if (
                    DesktopExperienceFlags.ENABLE_INTERACTION_DEPENDENT_TAB_TEARING_BOUNDS.isTrue()
                ) {
                    // Inherit parent's bounds.
                    newWindowBounds.set(taskInfo.configuration.windowConfiguration.bounds)
                    // TODO: (b/436504714) - Implement the new positioning logic here.
                } else {
                    // Use default bounds, but with the top-center at the drop point.
                    newWindowBounds.set(calculateDefaultDesktopTaskBounds(displayLayout))
                    newWindowBounds.offsetTo(
@@ -5712,6 +5719,7 @@ class DesktopTasksController(
                        dragEvent.y.toInt(),
                    )
                }
            }
            IndicatorType.TO_SPLIT_RIGHT_INDICATOR -> {
                newWindowBounds.set(getSnapBounds(destinationDisplay, SnapPosition.RIGHT))
            }
+64 −0
Original line number Diff line number Diff line
@@ -10020,6 +10020,70 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
            )
    }

    @Test
    @EnableFlags(
        Flags.FLAG_ENABLE_DESKTOP_TAB_TEARING_MINIMIZE_ANIMATION_BUGFIX,
        Flags.FLAG_ENABLE_DESKTOP_TAB_TEARING_LAUNCH_ANIMATION,
        Flags.FLAG_ENABLE_INTERACTION_DEPENDENT_TAB_TEARING_BOUNDS,
    )
    fun onUnhandledDrag_newWindowFromTabIntent_tabTearingAnimationBugfixFlagEnabled_tabTearingLaunchAnimationFlagEnabled() {
        testOnUnhandledDrag(
            DesktopModeVisualIndicator.IndicatorType.TO_DESKTOP_INDICATOR,
            PointF(1200f, 700f),
            Rect(100, 100, 300, 300),
            tabTearingMinimizeAnimationFlagEnabled = true,
            tabTearingLaunchAnimationFlagEnabled = true,
        )
    }

    @Test
    @EnableFlags(
        Flags.FLAG_ENABLE_DESKTOP_TAB_TEARING_MINIMIZE_ANIMATION_BUGFIX,
        Flags.FLAG_ENABLE_INTERACTION_DEPENDENT_TAB_TEARING_BOUNDS,
    )
    @DisableFlags(Flags.FLAG_ENABLE_DESKTOP_TAB_TEARING_LAUNCH_ANIMATION)
    fun onUnhandledDrag_newWindowFromTabIntent_tabTearingAnimationBugfixFlagEnabled_tabTearingLaunchAnimationFlagDisabled() {
        testOnUnhandledDrag(
            DesktopModeVisualIndicator.IndicatorType.TO_DESKTOP_INDICATOR,
            PointF(1200f, 700f),
            Rect(100, 100, 300, 300),
            tabTearingMinimizeAnimationFlagEnabled = true,
            tabTearingLaunchAnimationFlagEnabled = false,
        )
    }

    @Test
    @EnableFlags(
        Flags.FLAG_ENABLE_DESKTOP_TAB_TEARING_LAUNCH_ANIMATION,
        Flags.FLAG_ENABLE_INTERACTION_DEPENDENT_TAB_TEARING_BOUNDS,
        )
    @DisableFlags(Flags.FLAG_ENABLE_DESKTOP_TAB_TEARING_MINIMIZE_ANIMATION_BUGFIX)
    fun onUnhandledDrag_newWindowFromTabIntent_tabTearingAnimationBugfixFlagDisabled_tabTearingLaunchAnimationFlagEnabled() {
        testOnUnhandledDrag(
            DesktopModeVisualIndicator.IndicatorType.TO_DESKTOP_INDICATOR,
            PointF(1200f, 700f),
            Rect(100, 100, 300, 300),
            tabTearingMinimizeAnimationFlagEnabled = false,
            tabTearingLaunchAnimationFlagEnabled = true,
        )
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_INTERACTION_DEPENDENT_TAB_TEARING_BOUNDS)
    @DisableFlags(
        Flags.FLAG_ENABLE_DESKTOP_TAB_TEARING_MINIMIZE_ANIMATION_BUGFIX,
        Flags.FLAG_ENABLE_DESKTOP_TAB_TEARING_LAUNCH_ANIMATION,
    )
    fun onUnhandledDrag_newWindowFromTabIntent_tabTearingAnimationBugfixFlagDisabled_tabTearingLaunchAnimationFlagDisabled() {
        testOnUnhandledDrag(
            DesktopModeVisualIndicator.IndicatorType.TO_DESKTOP_INDICATOR,
            PointF(1200f, 700f),
            Rect(100, 100, 300, 300),
            tabTearingMinimizeAnimationFlagEnabled = false,
            tabTearingLaunchAnimationFlagEnabled = false,
        )
    }

    @Test
    @EnableFlags(
        Flags.FLAG_ENABLE_DESKTOP_TAB_TEARING_MINIMIZE_ANIMATION_BUGFIX,
+27 −0
Original line number Diff line number Diff line
@@ -53,6 +53,8 @@ import java.util.concurrent.atomic.AtomicInteger;
 * The class that defines default launch params for tasks in desktop mode
 */
class DesktopModeLaunchParamsModifier implements LaunchParamsModifier {
    private static final String ACTION_DRAG_DROP_VIEW =
            "org.chromium.chrome.browser.dragdrop.action.VIEW";
    private StringBuilder mLogBuilder;

    @NonNull
@@ -233,6 +235,10 @@ class DesktopModeLaunchParamsModifier implements LaunchParamsModifier {
                // ignore the source windowing mode and set the windowing mode to freeform.
                outParams.mWindowingMode = WINDOWING_MODE_FREEFORM;
                appendLog("freeform window mode applied to task trampoline");
                if (persisitSourceBoundsForTabTearingTrampoline(source, activity)) {
                    outParams.mBounds.set(sourceTask.getBounds());
                    return RESULT_DONE;
                }
            } else {
                // In Proto2, trampoline task launches of an existing background task can result in
                // the previous windowing mode to be restored even if the desktop mode state has
@@ -479,6 +485,27 @@ class DesktopModeLaunchParamsModifier implements LaunchParamsModifier {
                && isClosingExitingInstance(launchingTask.getBaseIntent().getFlags());
    }

    /**
     * Returns true if the bounds should be persisted from the source activity for
     * tab tearing trampoline launches.
     */
    private boolean persisitSourceBoundsForTabTearingTrampoline(
            @NonNull ActivityRecord source,
            @Nullable ActivityRecord activity) {
        return DesktopExperienceFlags.ENABLE_INTERACTION_DEPENDENT_TAB_TEARING_BOUNDS.isTrue()
                && activity != null
                && source.isNoDisplay()
                && source.packageName.equals(activity.packageName)
                && isChromiumDragAndDropAction(activity);
    }

    /**
     * Returns true if the given activity action is a chromium drag and drop.
     */
    private boolean isChromiumDragAndDropAction(@NonNull ActivityRecord activity) {
        return ACTION_DRAG_DROP_VIEW.equals(activity.intent.getAction());
    }

    /**
     * Returns true if the launch mode will result in a single new task being created for the
     * activity.