Skip to content

Commit

Permalink
Merge pull request #40555 from RandomShaper/fix_debugger_autofocus_3.2
Browse files Browse the repository at this point in the history
Fix debugger not getting focused on break on Windows (3.2)
  • Loading branch information
akien-mga authored Oct 1, 2020
2 parents 0a26217 + 633b75c commit 9da889f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 1 addition & 4 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
memdelete(sdr);
} else {
script_debugger = sdr;
sdr->set_allow_focus_steal_pid(allow_focus_steal_pid);
}
} else if (debug_mode == "local") {

Expand Down Expand Up @@ -1311,10 +1312,6 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
OS::get_singleton()->set_window_always_on_top(true);
}

if (allow_focus_steal_pid) {
OS::get_singleton()->enable_for_stealing_focus(allow_focus_steal_pid);
}

register_server_types();

MAIN_PRINT("Main: Load Remaps");
Expand Down
9 changes: 9 additions & 0 deletions scene/debugger/script_debugger_remote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue,

ERR_FAIL_COND_MSG(!tcp_client->is_connected_to_host(), "Script Debugger failed to connect, but being used anyway.");

if (allow_focus_steal_pid) {
OS::get_singleton()->enable_for_stealing_focus(allow_focus_steal_pid);
}

packet_peer_stream->put_var("debug_enter");
packet_peer_stream->put_var(2);
packet_peer_stream->put_var(p_can_continue);
Expand Down Expand Up @@ -1231,6 +1235,10 @@ void ScriptDebuggerRemote::set_skip_breakpoints(bool p_skip_breakpoints) {
skip_breakpoints = p_skip_breakpoints;
}

void ScriptDebuggerRemote::set_allow_focus_steal_pid(OS::ProcessID p_pid) {
allow_focus_steal_pid = p_pid;
}

ScriptDebuggerRemote::ResourceUsageFunc ScriptDebuggerRemote::resource_usage_func = NULL;

ScriptDebuggerRemote::ScriptDebuggerRemote() :
Expand Down Expand Up @@ -1258,6 +1266,7 @@ ScriptDebuggerRemote::ScriptDebuggerRemote() :
warn_count(0),
last_msec(0),
msec_count(0),
allow_focus_steal_pid(0),
locking(false),
poll_every(0),
scene_tree(NULL) {
Expand Down
3 changes: 3 additions & 0 deletions scene/debugger/script_debugger_remote.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ class ScriptDebuggerRemote : public ScriptDebugger {
uint64_t last_msec;
uint64_t msec_count;

OS::ProcessID allow_focus_steal_pid;

bool locking; //hack to avoid a deadloop
static void _print_handler(void *p_this, const String &p_string, bool p_error);

Expand Down Expand Up @@ -198,6 +200,7 @@ class ScriptDebuggerRemote : public ScriptDebugger {
virtual void set_skip_breakpoints(bool p_skip_breakpoints);

void set_scene_tree(SceneTree *p_scene_tree) { scene_tree = p_scene_tree; };
void set_allow_focus_steal_pid(OS::ProcessID p_pid);

ScriptDebuggerRemote();
~ScriptDebuggerRemote();
Expand Down

0 comments on commit 9da889f

Please sign in to comment.