You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-21 14:57:09 +00:00
[macOS] Forward application focus events to the embedded process.
This commit is contained in:
@@ -40,6 +40,7 @@ class LayerHost final : public Control {
|
|||||||
|
|
||||||
ScriptEditorDebugger *script_debugger = nullptr;
|
ScriptEditorDebugger *script_debugger = nullptr;
|
||||||
EmbeddedProcessMacOS *process = nullptr;
|
EmbeddedProcessMacOS *process = nullptr;
|
||||||
|
bool window_focused = true;
|
||||||
|
|
||||||
struct CustomCursor {
|
struct CustomCursor {
|
||||||
Ref<Image> image;
|
Ref<Image> image;
|
||||||
|
|||||||
@@ -252,6 +252,10 @@ void LayerHost::_notification(int p_what) {
|
|||||||
// Restore embedded process mouse mode.
|
// Restore embedded process mouse mode.
|
||||||
ds->mouse_set_mode(process->get_mouse_mode());
|
ds->mouse_set_mode(process->get_mouse_mode());
|
||||||
}
|
}
|
||||||
|
if (!window_focused && script_debugger) {
|
||||||
|
script_debugger->send_message("embed:win_event", { DisplayServer::WINDOW_EVENT_FOCUS_IN });
|
||||||
|
window_focused = true;
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
case NOTIFICATION_MOUSE_EXIT: {
|
case NOTIFICATION_MOUSE_EXIT: {
|
||||||
DisplayServer *ds = DisplayServer::get_singleton();
|
DisplayServer *ds = DisplayServer::get_singleton();
|
||||||
@@ -268,6 +272,10 @@ void LayerHost::_notification(int p_what) {
|
|||||||
if (ds->mouse_get_mode() != DisplayServer::MOUSE_MODE_VISIBLE) {
|
if (ds->mouse_get_mode() != DisplayServer::MOUSE_MODE_VISIBLE) {
|
||||||
ds->mouse_set_mode(DisplayServer::MOUSE_MODE_VISIBLE);
|
ds->mouse_set_mode(DisplayServer::MOUSE_MODE_VISIBLE);
|
||||||
}
|
}
|
||||||
|
if (window_focused && script_debugger) {
|
||||||
|
script_debugger->send_message("embed:win_event", { DisplayServer::WINDOW_EVENT_FOCUS_OUT });
|
||||||
|
window_focused = false;
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
case MainLoop::NOTIFICATION_OS_IME_UPDATE: {
|
case MainLoop::NOTIFICATION_OS_IME_UPDATE: {
|
||||||
if (script_debugger && has_focus()) {
|
if (script_debugger && has_focus()) {
|
||||||
@@ -285,6 +293,28 @@ void LayerHost::_notification(int p_what) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
case NOTIFICATION_WM_WINDOW_FOCUS_IN: {
|
||||||
|
if (!window_focused && script_debugger) {
|
||||||
|
script_debugger->send_message("embed:win_event", { DisplayServer::WINDOW_EVENT_FOCUS_IN });
|
||||||
|
window_focused = true;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case NOTIFICATION_WM_WINDOW_FOCUS_OUT: {
|
||||||
|
if (window_focused && script_debugger) {
|
||||||
|
script_debugger->send_message("embed:win_event", { DisplayServer::WINDOW_EVENT_FOCUS_OUT });
|
||||||
|
window_focused = false;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case NOTIFICATION_APPLICATION_FOCUS_IN: {
|
||||||
|
if (script_debugger) {
|
||||||
|
script_debugger->send_message("embed:notification", { NOTIFICATION_APPLICATION_FOCUS_IN });
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case NOTIFICATION_APPLICATION_FOCUS_OUT: {
|
||||||
|
if (script_debugger) {
|
||||||
|
script_debugger->send_message("embed:notification", { NOTIFICATION_APPLICATION_FOCUS_OUT });
|
||||||
|
}
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ private:
|
|||||||
Error _msg_mouse_set_mode(const Array &p_args);
|
Error _msg_mouse_set_mode(const Array &p_args);
|
||||||
Error _msg_event(const Array &p_args);
|
Error _msg_event(const Array &p_args);
|
||||||
Error _msg_win_event(const Array &p_args);
|
Error _msg_win_event(const Array &p_args);
|
||||||
|
Error _msg_notification(const Array &p_args);
|
||||||
Error _msg_ime_update(const Array &p_args);
|
Error _msg_ime_update(const Array &p_args);
|
||||||
Error _msg_joy_add(const Array &p_args);
|
Error _msg_joy_add(const Array &p_args);
|
||||||
Error _msg_joy_del(const Array &p_args);
|
Error _msg_joy_del(const Array &p_args);
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ void EmbeddedDebugger::_init_parse_message_handlers() {
|
|||||||
parse_message_handlers["mouse_set_mode"] = &EmbeddedDebugger::_msg_mouse_set_mode;
|
parse_message_handlers["mouse_set_mode"] = &EmbeddedDebugger::_msg_mouse_set_mode;
|
||||||
parse_message_handlers["event"] = &EmbeddedDebugger::_msg_event;
|
parse_message_handlers["event"] = &EmbeddedDebugger::_msg_event;
|
||||||
parse_message_handlers["win_event"] = &EmbeddedDebugger::_msg_win_event;
|
parse_message_handlers["win_event"] = &EmbeddedDebugger::_msg_win_event;
|
||||||
|
parse_message_handlers["notification"] = &EmbeddedDebugger::_msg_notification;
|
||||||
parse_message_handlers["ime_update"] = &EmbeddedDebugger::_msg_ime_update;
|
parse_message_handlers["ime_update"] = &EmbeddedDebugger::_msg_ime_update;
|
||||||
parse_message_handlers["joy_add"] = &EmbeddedDebugger::_msg_joy_add;
|
parse_message_handlers["joy_add"] = &EmbeddedDebugger::_msg_joy_add;
|
||||||
parse_message_handlers["joy_del"] = &EmbeddedDebugger::_msg_joy_del;
|
parse_message_handlers["joy_del"] = &EmbeddedDebugger::_msg_joy_del;
|
||||||
@@ -151,6 +152,15 @@ Error EmbeddedDebugger::_msg_ime_update(const Array &p_args) {
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Error EmbeddedDebugger::_msg_notification(const Array &p_args) {
|
||||||
|
ERR_FAIL_COND_V_MSG(p_args.size() != 1, ERR_INVALID_PARAMETER, "Invalid number of arguments for 'notification' message.");
|
||||||
|
int notification = p_args[0];
|
||||||
|
if (OS::get_singleton()->get_main_loop()) {
|
||||||
|
OS::get_singleton()->get_main_loop()->notification(notification);
|
||||||
|
}
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
Error EmbeddedDebugger::_msg_joy_add(const Array &p_args) {
|
Error EmbeddedDebugger::_msg_joy_add(const Array &p_args) {
|
||||||
ERR_FAIL_COND_V_MSG(p_args.size() != 2, ERR_INVALID_PARAMETER, "Invalid number of arguments for 'joy_add' message.");
|
ERR_FAIL_COND_V_MSG(p_args.size() != 2, ERR_INVALID_PARAMETER, "Invalid number of arguments for 'joy_add' message.");
|
||||||
int idx = p_args[0];
|
int idx = p_args[0];
|
||||||
|
|||||||
Reference in New Issue
Block a user