From 0eb9d6648f01c6c59756ce8921c072d57d325c88 Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 8 Feb 2023 09:25:47 +0100 Subject: [PATCH] Added a setting to force launch the project in an adjacent window in the android editor. --- editor/editor_run.cpp | 16 ++++++++++++---- editor/editor_settings.cpp | 17 ++++++++++------- .../pandemonium/editor/PandemoniumEditor.kt | 9 +++++++++ 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index b472d09fe..1875ca08a 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -32,16 +32,16 @@ #include -#include "plugins/script_editor_plugin.h" -#include "script_editor_debugger.h" #include "core/config/project_settings.h" -#include "editor_settings.h" +#include "core/containers/vector.h" #include "core/error/error_macros.h" #include "core/math/math_funcs.h" #include "core/math/rect2.h" #include "core/math/vector2.h" #include "core/variant/variant.h" -#include "core/containers/vector.h" +#include "editor_settings.h" +#include "plugins/script_editor_plugin.h" +#include "script_editor_debugger.h" EditorRun::Status EditorRun::get_status() const { return status; @@ -74,6 +74,14 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L } #endif +#ifdef ANDROID_ENABLED + const bool android_force_side_by_side_window = EditorSettings::get_singleton()->get("run/window_placement/android_force_launch_adjacent"); + + if (android_force_side_by_side_window) { + args.push_back("--android-force-launch-adjacent"); + } +#endif + args.push_back("--allow_focus_steal_pid"); args.push_back(itos(OS::get_singleton()->get_process_id())); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 3474628a4..b272edfb9 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -30,32 +30,32 @@ #include "editor_settings.h" -#include "core/variant/array.h" -#include "core/object/class_db.h" -#include "core/math/color.h" -#include "core/variant/dictionary.h" +#include "core/config/project_settings.h" +#include "core/containers/rb_set.h" #include "core/error/error_list.h" #include "core/error/error_macros.h" +#include "core/input/input_event.h" #include "core/io/certs_compressed.gen.h" #include "core/io/config_file.h" #include "core/io/ip.h" #include "core/io/ip_address.h" #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" +#include "core/math/color.h" #include "core/math/math_funcs.h" #include "core/math/vector2.h" +#include "core/object/class_db.h" #include "core/os/dir_access.h" #include "core/os/file_access.h" -#include "core/input/input_event.h" #include "core/os/keyboard.h" #include "core/os/main_loop.h" #include "core/os/memory.h" #include "core/os/os.h" #include "core/string/print_string.h" -#include "core/config/project_settings.h" -#include "core/containers/rb_set.h" #include "core/string/translation.h" #include "core/typedefs.h" +#include "core/variant/array.h" +#include "core/variant/dictionary.h" #include "core/version_generated.gen.h" #include "editor/editor_translation.h" #include "scene/main/node.h" @@ -642,6 +642,9 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { _initial_set("run/window_placement/rect_custom_position", Vector2()); _initial_set("run/window_placement/screen", 0); hints["run/window_placement/screen"] = PropertyInfo(Variant::INT, "run/window_placement/screen", PROPERTY_HINT_ENUM, screen_hints); +#ifdef ANDROID_ENABLED + _initial_set("run/window_placement/android_force_launch_adjacent", 0); +#endif // Auto save _initial_set("run/auto_save/save_before_running", true); diff --git a/platform/android/java/editor/src/main/java/net/relintai/pandemonium/editor/PandemoniumEditor.kt b/platform/android/java/editor/src/main/java/net/relintai/pandemonium/editor/PandemoniumEditor.kt index 5452c3718..1de73cf02 100644 --- a/platform/android/java/editor/src/main/java/net/relintai/pandemonium/editor/PandemoniumEditor.kt +++ b/platform/android/java/editor/src/main/java/net/relintai/pandemonium/editor/PandemoniumEditor.kt @@ -76,6 +76,8 @@ open class PandemoniumEditor : FullScreenPandemoniumApp() { private const val PROJECT_MANAGER_ARG = "--project-manager" private const val PROJECT_MANAGER_ARG_SHORT = "-p" private const val PROJECT_MANAGER_PROCESS_NAME_SUFFIX = ":PandemoniumProjectManager" + + private const val FORCE_LAUNCH_ADJACENT_ARG = "--android-force-launch-adjacent" } private val commandLineParams = ArrayList() @@ -135,6 +137,13 @@ open class PandemoniumEditor : FullScreenPandemoniumApp() { } } + for (arg in args) { + if (FORCE_LAUNCH_ADJACENT_ARG == arg) { + launchAdjacent = true + break + } + } + // Launch a new activity val newInstance = Intent(this, targetClass).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).putExtra(COMMAND_LINE_PARAMS, args)