Skip to content

Commit 4ab3584

Browse files
committed
Merge pull request godotengine#96340 from m4gr3d/update_pip_mode_options
[Android Editor] Update the options for launching the Play window in PiP mode
2 parents dbdc4eb + 11d4df4 commit 4ab3584

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

doc/classes/EditorSettings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,7 @@
970970
- [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.
971971
- [b]Same as Editor[/b] will launch the Play window in the same window as the Editor.
972972
- [b]Side-by-side with Editor[/b] will launch the Play window side-by-side with the Editor window.
973+
- [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.
973974
[b]Note:[/b] Only available in the Android editor.
974975
</member>
975976
<member name="run/window_placement/play_window_pip_mode" type="int" setter="" getter="">

editor/editor_settings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
824824
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "run/window_placement/screen", -5, screen_hints)
825825
#endif
826826
// Should match the ANDROID_WINDOW_* constants in 'platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.kt'
827-
String android_window_hints = "Auto (based on screen size):0,Same as Editor:1,Side-by-side with Editor:2";
827+
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";
828828
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "run/window_placement/android_window", 0, android_window_hints)
829829

830830
int default_play_window_pip_mode = 0;

platform/android/java/editor/src/main/java/org/godotengine/editor/EditorWindowInfo.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ enum class LaunchPolicy {
4848
/**
4949
* Adjacent launches are enabled.
5050
*/
51-
ADJACENT
51+
ADJACENT,
52+
53+
/**
54+
* Launches happen in the same window but start in PiP mode.
55+
*/
56+
SAME_AND_LAUNCH_IN_PIP_MODE
5257
}
5358

5459
/**

platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.kt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ open class GodotEditor : GodotActivity() {
101101
private const val ANDROID_WINDOW_AUTO = 0
102102
private const val ANDROID_WINDOW_SAME_AS_EDITOR = 1
103103
private const val ANDROID_WINDOW_SIDE_BY_SIDE_WITH_EDITOR = 2
104+
private const val ANDROID_WINDOW_SAME_AS_EDITOR_AND_LAUNCH_IN_PIP_MODE = 3
104105

105106
/**
106107
* Sets of constants to specify the Play window PiP mode.
@@ -244,25 +245,30 @@ open class GodotEditor : GodotActivity() {
244245
val isPiPAvailable = if (editorWindowInfo.supportsPiPMode && hasPiPSystemFeature()) {
245246
val pipMode = getPlayWindowPiPMode()
246247
pipMode == PLAY_WINDOW_PIP_ENABLED ||
247-
(pipMode == PLAY_WINDOW_PIP_ENABLED_FOR_SAME_AS_EDITOR && launchPolicy == LaunchPolicy.SAME)
248+
(pipMode == PLAY_WINDOW_PIP_ENABLED_FOR_SAME_AS_EDITOR &&
249+
(launchPolicy == LaunchPolicy.SAME || launchPolicy == LaunchPolicy.SAME_AND_LAUNCH_IN_PIP_MODE))
248250
} else {
249251
false
250252
}
251253
newInstance.putExtra(EXTRA_PIP_AVAILABLE, isPiPAvailable)
252254

255+
var launchInPiP = false
253256
if (launchPolicy == LaunchPolicy.ADJACENT) {
254257
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
255258
Log.v(TAG, "Adding flag for adjacent launch")
256259
newInstance.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT)
257260
}
258261
} else if (launchPolicy == LaunchPolicy.SAME) {
259-
if (isPiPAvailable &&
260-
(updatedArgs.contains(BREAKPOINTS_ARG) || updatedArgs.contains(BREAKPOINTS_ARG_SHORT))) {
261-
Log.v(TAG, "Launching in PiP mode because of breakpoints")
262-
newInstance.putExtra(EXTRA_LAUNCH_IN_PIP, true)
263-
}
262+
launchInPiP = isPiPAvailable &&
263+
(updatedArgs.contains(BREAKPOINTS_ARG) || updatedArgs.contains(BREAKPOINTS_ARG_SHORT))
264+
} else if (launchPolicy == LaunchPolicy.SAME_AND_LAUNCH_IN_PIP_MODE) {
265+
launchInPiP = isPiPAvailable
264266
}
265267

268+
if (launchInPiP) {
269+
Log.v(TAG, "Launching in PiP mode")
270+
newInstance.putExtra(EXTRA_LAUNCH_IN_PIP, launchInPiP)
271+
}
266272
return newInstance
267273
}
268274

@@ -403,6 +409,7 @@ open class GodotEditor : GodotActivity() {
403409
when (Integer.parseInt(GodotLib.getEditorSetting("run/window_placement/android_window"))) {
404410
ANDROID_WINDOW_SAME_AS_EDITOR -> LaunchPolicy.SAME
405411
ANDROID_WINDOW_SIDE_BY_SIDE_WITH_EDITOR -> LaunchPolicy.ADJACENT
412+
ANDROID_WINDOW_SAME_AS_EDITOR_AND_LAUNCH_IN_PIP_MODE -> LaunchPolicy.SAME_AND_LAUNCH_IN_PIP_MODE
406413
else -> {
407414
// ANDROID_WINDOW_AUTO
408415
defaultLaunchPolicy

0 commit comments

Comments
 (0)