diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml index b6565b81f22..4ebbed6b812 100644 --- a/doc/classes/EditorSettings.xml +++ b/doc/classes/EditorSettings.xml @@ -967,6 +967,7 @@ - [b]Auto (based on screen size)[/b] (default) will automatically choose how to launch the Play window based on the device and screen metrics. Defaults to [b]Same as Editor[/b] on phones and [b]Side-by-side with Editor[/b] on tablets. - [b]Same as Editor[/b] will launch the Play window in the same window as the Editor. - [b]Side-by-side with Editor[/b] will launch the Play window side-by-side with the Editor window. + - [b]Launch in PiP mode[/b] will launch the Play window directly in picture-in-picture (PiP) mode if PiP mode is supported and enabled. When maximized, the Play window will occupy the same window as the Editor. [b]Note:[/b] Only available in the Android editor. diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index b5c11b574ed..f23f3d69688 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -824,7 +824,7 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "run/window_placement/screen", -5, screen_hints) #endif // Should match the ANDROID_WINDOW_* constants in 'platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.kt' - String android_window_hints = "Auto (based on screen size):0,Same as Editor:1,Side-by-side with Editor:2"; + String android_window_hints = "Auto (based on screen size):0,Same as Editor:1,Side-by-side with Editor:2,Launch in PiP mode:3"; EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "run/window_placement/android_window", 0, android_window_hints) int default_play_window_pip_mode = 0; diff --git a/platform/android/java/editor/src/main/java/org/godotengine/editor/EditorWindowInfo.kt b/platform/android/java/editor/src/main/java/org/godotengine/editor/EditorWindowInfo.kt index d3daa1dbbc8..2e1de9a6070 100644 --- a/platform/android/java/editor/src/main/java/org/godotengine/editor/EditorWindowInfo.kt +++ b/platform/android/java/editor/src/main/java/org/godotengine/editor/EditorWindowInfo.kt @@ -48,7 +48,12 @@ enum class LaunchPolicy { /** * Adjacent launches are enabled. */ - ADJACENT + ADJACENT, + + /** + * Launches happen in the same window but start in PiP mode. + */ + SAME_AND_LAUNCH_IN_PIP_MODE } /** diff --git a/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.kt b/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.kt index 1995a38c2a8..405b2fb57f8 100644 --- a/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.kt +++ b/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.kt @@ -101,6 +101,7 @@ open class GodotEditor : GodotActivity() { private const val ANDROID_WINDOW_AUTO = 0 private const val ANDROID_WINDOW_SAME_AS_EDITOR = 1 private const val ANDROID_WINDOW_SIDE_BY_SIDE_WITH_EDITOR = 2 + private const val ANDROID_WINDOW_SAME_AS_EDITOR_AND_LAUNCH_IN_PIP_MODE = 3 /** * Sets of constants to specify the Play window PiP mode. @@ -244,25 +245,30 @@ open class GodotEditor : GodotActivity() { val isPiPAvailable = if (editorWindowInfo.supportsPiPMode && hasPiPSystemFeature()) { val pipMode = getPlayWindowPiPMode() pipMode == PLAY_WINDOW_PIP_ENABLED || - (pipMode == PLAY_WINDOW_PIP_ENABLED_FOR_SAME_AS_EDITOR && launchPolicy == LaunchPolicy.SAME) + (pipMode == PLAY_WINDOW_PIP_ENABLED_FOR_SAME_AS_EDITOR && + (launchPolicy == LaunchPolicy.SAME || launchPolicy == LaunchPolicy.SAME_AND_LAUNCH_IN_PIP_MODE)) } else { false } newInstance.putExtra(EXTRA_PIP_AVAILABLE, isPiPAvailable) + var launchInPiP = false if (launchPolicy == LaunchPolicy.ADJACENT) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { Log.v(TAG, "Adding flag for adjacent launch") newInstance.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT) } } else if (launchPolicy == LaunchPolicy.SAME) { - if (isPiPAvailable && - (updatedArgs.contains(BREAKPOINTS_ARG) || updatedArgs.contains(BREAKPOINTS_ARG_SHORT))) { - Log.v(TAG, "Launching in PiP mode because of breakpoints") - newInstance.putExtra(EXTRA_LAUNCH_IN_PIP, true) - } + launchInPiP = isPiPAvailable && + (updatedArgs.contains(BREAKPOINTS_ARG) || updatedArgs.contains(BREAKPOINTS_ARG_SHORT)) + } else if (launchPolicy == LaunchPolicy.SAME_AND_LAUNCH_IN_PIP_MODE) { + launchInPiP = isPiPAvailable } + if (launchInPiP) { + Log.v(TAG, "Launching in PiP mode") + newInstance.putExtra(EXTRA_LAUNCH_IN_PIP, launchInPiP) + } return newInstance } @@ -403,6 +409,7 @@ open class GodotEditor : GodotActivity() { when (Integer.parseInt(GodotLib.getEditorSetting("run/window_placement/android_window"))) { ANDROID_WINDOW_SAME_AS_EDITOR -> LaunchPolicy.SAME ANDROID_WINDOW_SIDE_BY_SIDE_WITH_EDITOR -> LaunchPolicy.ADJACENT + ANDROID_WINDOW_SAME_AS_EDITOR_AND_LAUNCH_IN_PIP_MODE -> LaunchPolicy.SAME_AND_LAUNCH_IN_PIP_MODE else -> { // ANDROID_WINDOW_AUTO defaultLaunchPolicy