From e8fb68e038bddbb82653550cd2854fc5c5d6891b Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 20 Aug 2017 23:42:54 -0300 Subject: [PATCH] simplify the way window is allowed to steal focus, no longer relying on project.godot. Closes #9459 (cherry picked from commit 533014b88c964044441dc04dce6e757b0776de97) --- core/script_debugger_remote.cpp | 2 -- editor/editor_run.cpp | 4 ++-- main/main.cpp | 11 ++++++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index c838c1d2785..c7fc1e48d9e 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -130,8 +130,6 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue) ERR_FAIL(); } - OS::get_singleton()->enable_for_stealing_focus(Globals::get_singleton()->get("editor_pid")); - packet_peer_stream->put_var("debug_enter"); packet_peer_stream->put_var(2); packet_peer_stream->put_var(p_can_continue); diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index 4c0d3a26eca..5569879d9d2 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -53,8 +53,8 @@ Error EditorRun::run(const String &p_scene, const String p_custom_args, const Li args.push_back(remote_host + ":" + String::num(remote_port)); } - args.push_back("-epid"); - args.push_back(String::num(OS::get_singleton()->get_process_ID())); + args.push_back("-allow_focus_steal_pid"); + args.push_back(itos(OS::get_singleton()->get_process_ID())); if (debug_collisions) { args.push_back("-debugcol"); diff --git a/main/main.cpp b/main/main.cpp index 78239e60e77..369b24dc3cc 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -110,6 +110,8 @@ static int init_screen = -1; static bool use_vsync = true; static bool editor = false; +static OS::ProcessID allow_focus_steal_pid = 0; + static String unescape_cmdline(const String &p_str) { return p_str.replace("%20", " "); @@ -527,11 +529,10 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph } else { goto error; } - } else if (I->get() == "-epid") { + } else if (I->get() == "-allow_focus_steal_pid") { if (I->next()) { - int editor_pid = I->next()->get().to_int(); - Globals::get_singleton()->set("editor_pid", editor_pid); + allow_focus_steal_pid = I->next()->get().to_int64(); N = I->next()->next(); } else { goto error; @@ -958,6 +959,10 @@ Error Main::setup2() { EditorNode::register_editor_types(); #endif + if (allow_focus_steal_pid) { + OS::get_singleton()->enable_for_stealing_focus(allow_focus_steal_pid); + } + MAIN_PRINT("Main: Load Scripts, Modules, Drivers"); register_module_types();